Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 110690

How Can I add a some functions into script?

$
0
0

Hi, everyone

 

I got this script:

 

if ( app.selection.length > 0 && ( app.selection[0].constructor.name == "Cell" || app.selection[0].constructor.name == "Table" ) ) {  

    if ( app.scriptPreferences.version >= 6 ) { 

        app.doScript( main, ScriptLanguage.JAVASCRIPT , [], UndoModes.ENTIRE_SCRIPT, "style every second column in selection" );          

    }  

    else { 

        main(); 

    } 

} else { 

    alert ( "Nothing or wrong selection!" ); 

 

function main() { 

     

    var myColor = "Black"; 

    var myFillTint = 20; 

    var myCharStyleName = "Bold"; 

    var myStrokeWeight = 0.5; 

 

    var curSel = app.selection[0]; 

    var allCells = curSel.cells; 

    var startCol = curSel.cells[0].name.split(":")[0]*1;    

    var endCol = curSel.cells[-1].name.split(":")[0]*1; 

    var startRow = curSel.cells[0].name.split(":")[1]*1;    

    var endRow = curSel.cells[-1].name.split(":")[1]*1;   

    var counter = startCol + 1; 

 

    for ( var i = 0 ; i < allCells.length; i++ ) { 

        var curCell = allCells[i]; 

        var curCol = curCell.name.split(":")[0]*1; 

        var curRow = curCell.name.split(":")[1]*1; 

 

        if ( curCol == counter ) { 

            with ( curCell ) { 

                fillColor = myColor; 

                fillTint = myFillTint; 

                texts[0].appliedCharacterStyle = myCharStyleName; 

                rightEdgeStrokeWeight = myStrokeWeight; 

                rightEdgeStrokeColor= myColor;  

                leftEdgeStrokeWeight = myStrokeWeight; 

                leftEdgeStrokeColor= myColor;                  

            } 

            if ( curRow == startRow ) { 

                curCell.topEdgeStrokeWeight = myStrokeWeight; 

                curCell.topEdgeStrokeColor= myColor; 

            } 

            else if (curRow == endRow ) { 

                curCell.bottomEdgeStrokeWeight = myStrokeWeight; 

                curCell.bottomEdgeStrokeColor= myColor; 

            } 

             

            counter = counter + 2; 

        } 

         

        if ( counter > endCol ) { 

            counter = startCol + 1; 

        } // end if 

    } // end for 

} // end main

 

which made by Kai Rübsamen

 

Can cells like this:

 

before

 

modify cell before.jpg

 

After

 

modify cell after.jpg

 

but what if I want add a function into it, let the script can make dollar sign italic?

like this:

 

modify cell add to it.jpg

I expected it can let me thoose which row I want to make it Bold+Italic, and Italic

 

How can I do that?

 

John


Viewing all articles
Browse latest Browse all 110690

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>