I had try to set the objectstyle before, but it doesn't work......
var myDoc = app.activeDocument;
myDoc.objectStyles.itemByName("Japan_one").anchoredObjectSettings.anchorXoffset = 210;
I checked the "Japan_one" style changed the value to 210.......
but nothing happen..............so I don't know how to make it work......
Oh yes. What you did is correct, but there is an extra part: because in your documents the Japan_one object style has been overridden on the objects (see the + symbol in the Object Styles panel). So your script needs to clear those overrides. There is a method of TextFrame that does it. See this script:
function main() {
var docs = app.documents,
counter = 0;
// change all open documents
for (var d = 0; d < docs.length; d++) {
var doc = docs[d];
var myStyle = doc.objectStyles.itemByName("Japan_one");
if (!myStyle.isValid)
continue;
// first set correct value in the object style
myStyle.anchoredObjectSettings.anchorXoffset = "210 mm";
app.findObjectPreferences = null;
app.changeObjectPreferences = null;
app.findObjectPreferences.appliedObjectStyles = "Japan_one";
var found = doc.findObject();
counter += found.length;
for (var i = 0; i < found.length; i++)
// then clear overrides for each found object
found[i].clearObjectStyleOverrides();
}
alert('' + counter + ' objects changed.');
};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Fix Object Style');
I hope you can see what's happening there. But remember, clearing overrides means that if other changes were made, to diverge from the object style, then those changes will be lost. (That might be a good thing, it depends.)
- Mark