Skip to main content
BEGINNER_X
Legend
July 17, 2013
Answered

Apply Object Style for Anchor

  • July 17, 2013
  • 1 reply
  • 603 views

Hi All,

Could anyone please give solution for my request.

1. Find Anchor marker

2. Apply object style for that selecting parent Graphics frame.

var myDoc = app.activeDocument;

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.appliedParagraphStyle = "abc"

app.findGrepPreferences.findWhat = "~a"

var myFound = myDoc.findGrep();

for(i=0; i<myFound.length; i++)

{

    myFound.parentTextFrames[0].appliedObjectStyle = app.activeDocument.objectStyles.item("Image")   //Error this only

    }

Thanks in advance

Beginner

This topic has been closed for replies.
Correct answer milligramme

Hi

An anchored object is not parent but child(pageItem) for anchor.

myFound.parentTextFrames[0].appliedObjectStyle = app.activeDocument.objectStyles.item("Image")   //Error this only

try this code

myFound.pageItems[0].appliedObjectStyle = app.activeDocument.objectStyles.item("Image");

thankyou

mg.

1 reply

milligramme
milligrammeCorrect answer
Inspiring
July 18, 2013

Hi

An anchored object is not parent but child(pageItem) for anchor.

myFound.parentTextFrames[0].appliedObjectStyle = app.activeDocument.objectStyles.item("Image")   //Error this only

try this code

myFound.pageItems[0].appliedObjectStyle = app.activeDocument.objectStyles.item("Image");

thankyou

mg.