Skip to main content
Inspiring
January 19, 2015
Answered

Correct my script please!

  • January 19, 2015
  • 6 replies
  • 955 views

Hi everyone

Could someone please help me to correct my script:

var docs = app.documents;

for (var i = docs.length-1; i >= 0; i--) 

        {

            var
myTarget = app.target[0]; 

if(myTarget instanceof InsertionPoint)

{myTarget.insertionPoints[0].underline=false;

                                            }

else if(myTarget instanceof Cell)

                                {for(i=0; i<myTarget.cells.length; i++)

{myTarget.cells.texts[0].select();

                                        app.selection[0].underline=false;

                                            }

                                        }

else if(myTarget instanceof Table)

                                {for(i=0; i<myTarget.cells.length; i++)

{myTarget.cells.texts[0].select();

app.selection[0].underline=false;

                                            }

              }

else{myTarget.underline=false;

                                }

                            }

Aim to clear the underline which in the inserpoint, cells,
tables, text.

Thanks

Regard

 

Teetan

This topic has been closed for replies.
Correct answer Sajeev Sridharan

Just merge the two code and run.

Vandy

6 replies

Teetan_VKAuthor
Inspiring
January 19, 2015

thank you Jongware

thank you for you opinion,

I will try to solve problem by myself

thanks

Teetan

Jongware
Community Expert
Community Expert
January 19, 2015

For future questions:

Please do not use non-descriptive titles such as "Correct my script please", "Change script function", "Correct script"  or "Can you change script function?". Try to write a short, comprehensive title that describes the problem. Your older questions had better titles: "How can I set a point size for staticTexts", "How can find-change grep only on Masters", and so on. I guess you just became lazy because you got all the answers you were looking for.

Actually, the same goes for questions such as " can you make a script for ..." You are asking people to write up a script from scratch -- the forum is meant to help you, but not this way! At least try something yourself.

Also, please do not ever dump a script into your post and ask anyone to "fix it" -- the very least you could have done is tell what's wrong with it!

Teetan_VKAuthor
Inspiring
January 19, 2015

Thank you Vandy

thank you very much

Teetan

Teetan_VKAuthor
Inspiring
January 19, 2015

Hi Vandy

It will only work in empty cells

but not others

Thanks

Teetan

Sajeev SridharanCorrect answer
Legend
January 19, 2015

Just merge the two code and run.

Vandy

Teetan_VKAuthor
Inspiring
January 19, 2015

use find/change function will still can find the underline

Legend
January 19, 2015

Try this, the below code will sort out the empty cell problem:

var myDocs = app.documents;

for (var i = myDocs.length-1; i >= 0; i--) 

    for (s=0; s<myDocs.stories.length; s++)

    {

        for (t=0; t<myDocs.stories.tables.length; t++)

        {

            for (c=0; c<myDocs.stories.tables.cells.length; c++)

            {

                if(myDocs.stories.tables.cells.contents == "" && myDocs.stories.tables.cells.texts[0].underline==true)

                {

                    myDocs.stories.tables.cells.texts[0].underline=false;

                }

            }

        }

    }

}

Vandy

Legend
January 19, 2015

Have you provided the complete script, I think some lines are missing. If the provided code was complete one then why are you using app.documents for finding insertionpoints, tables, etc.

How the code will recognize which underline needs to be removed, could you explain clearly.

This may help you...

var mySelection = app.selection[0];

if(mySelection instanceof InsertionPoint)

{mySelection.insertionPoints[0].underline=false;}

else if(mySelection instanceof Cell)

{for(i=0; i<mySelection.cells.length; i++){mySelection.cells.texts[0].select();app.selection[0].underline=false;}}

else if(mySelection instanceof Table)

{for(i=0; i<mySelection.cells.length; i++){mySelection.cells.texts[0].select();app.selection[0].underline=false;}}

else{mySelection.underline=false;}

Vandy

Teetan_VKAuthor
Inspiring
January 19, 2015

Sorry Vandy

I make a big mistake, My aim is to clear the underline

no matter

in empty cells, cells' text, table, sotries everyitem, in my opening docs

Teetan

Teetan_VKAuthor
Inspiring
January 19, 2015

sorry all opening docs