Copy link to clipboard
Copied
Dear Pros,
I Want to release anchored objects that have specific paragraph and/or Object style in all document?
can this is be done? or shall i have script? do you know script doing this?
Best Regards
Mohammad
It can be done through script using the releaseAnchoredObject method from an object's anchoredObjectSettings.
Some pseudocode:
if (pageItem.condition is met) {
pageItem.anchoredObjectSettings.releaseAnchoredObject();
}
Sorry it should be if foundObjects[i].appliedObjectStyle.name == "ObjStyle"
Or,
if (foundObjects [i].appliedObjectStyle == myDoc.objectStyles.itemByName("ObjStyle")
Copy link to clipboard
Copied
Yes, it sounds like it would need to be scripted (it's not a built-in feature). No, not being a scripter, nor ever needing this feature, I don't know if anyone has developed it.
Copy link to clipboard
Copied
Thank you very much
Copy link to clipboard
Copied
It can be done through script using the releaseAnchoredObject method from an object's anchoredObjectSettings.
Some pseudocode:
if (pageItem.condition is met) {
pageItem.anchoredObjectSettings.releaseAnchoredObject();
}
Copy link to clipboard
Copied
Actually i have some experience in scripting, i wrote this script in the begining of the year to release all the anchored objects in the documents but i have a little experience in how to connecting the Styles with variables, here is the code if you can help to modify it to match object style - i will be thankful :
//Unanchored all Anchored Objects at Once
//Developed By : Mohammad Ibrahim
// 11-2-2020
//Check if a Document is Open
if (app.documents.length == 0) {
alert (“No document is open.”, “Caution”);
exit();
}
//Working in the Current Active Document
var myDoc = app.activeDocument;
// to use to process entire document
var myItems = myDoc.allPageItems;
// to use to process just current page
//var myItems = app.activeWindow.activePage.allPageItems;
//Creating Founded Objects Array
var foundObjects = Array();
for(var i = 0; i < myItems.length; i++){
if(myItems[i].parent instanceof Character){foundObjects.push(myItems[i]);}
}
//Check if Anchored Objects not Found
if ( myItems.length == 0 )
{
alert(“No Anchored items found in this document!.”, “Stop” );
exit();
}
//UnAnchored Process Started at Array Created
if(foundObjects.length > 0){
for(var i = 0; i < foundObjects.length; i++){
foundObjects[i].anchoredObjectSettings.anchoredPosition = AnchorPosition.anchored;
var AnchoredObject = foundObjects[i].anchoredObjectSettings.releaseAnchoredObject();
}
}
//Check if the Program is Done
if (AnchoredObject < 0) {
alert (“all Objects Done.”, “Stop”);
exit();
}
Copy link to clipboard
Copied
Thank you a lot
Copy link to clipboard
Copied
Add:
if (foundObjects[i].appliedObjectStyle == "Style to Find")
in the last for loop as a check before you release it.
Copy link to clipboard
Copied
Thank you very much for your reply, i tried it and no errors but not working!
//Unanchored all Anchored Objects at Once
//Check if a Document is Open
if (app.documents.length == 0) {
alert ("No document is open.", "Caution");
exit();
}
//Working in the Current Active Document
var myDoc = app.activeDocument;
// to use to process entire document
var myItems = myDoc.allPageItems;
//Creating Founded Objects Array
var foundObjects = Array();
for(var i = 0; i < myItems.length; i++){
if(myItems[i].parent instanceof Character){foundObjects.push(myItems[i]);}
}
//Check if Anchored Objects not Found
if ( myItems.length == 0 )
{
alert("No Anchored items found in this document!.", "Stop" );
exit();
}
//UnAnchored Process Started at Array Created
if(foundObjects.length > 0){
for(var i = 0; i < foundObjects.length; i++){
if (foundObjects[i].appliedObjectStyle == "ObjStyle") {
foundObjects[i].anchoredObjectSettings.anchoredPosition = AnchorPosition.anchored;
var AnchoredObject = foundObjects[i].anchoredObjectSettings.releaseAnchoredObject();
}
}
}
//Check if the Program is Done
if (AnchoredObject < 0) {
alert ("all Objects Done.", "Stop");
exit();
}
Copy link to clipboard
Copied
Sorry it should be if foundObjects[i].appliedObjectStyle.name == "ObjStyle"
Or,
if (foundObjects [i].appliedObjectStyle == myDoc.objectStyles.itemByName("ObjStyle")
Copy link to clipboard
Copied
Thank you a lot