Need advise. I want to unlock (if exist), delete existing guides & then create new guides .25 inches around the document. The doc size 7.937 x 9.75. I have margins created but don’t know what is happening with new ruler guides.
tell application "Adobe InDesign CS4"
activate
set myDocument to document 1
tell view preferences of active document
--Set horizontal and vertical measurement units to inches.
set ruler origin to page origin
set horizontal measurement units to inches
set vertical measurement units to inches
end tell
set myMasterSpread to master spread 1 of myDocument
tell margin preferences of page 1 of myMasterSpread
-- page margins and columns.
set left to ".5" --outside
set top to ".5 in"
set right to ".75 in" --inside
set bottom to ".75 in"
end tell
--Page margins and columns for the right-hand page.
tell margin preferences of page 2 of myMasterSpread
set left to ".5" --inside
set top to ".5 in"
set right to ".75 in" --outside
set bottom to ".5 in"
end tell
tell myDocument
--unlock all guides
set guides locked to false
--tell guide preferences of document 1
delete guides
set ruler guides color to "light blue"
set vertPos to {".25 in", "7.6875"} --left & right vertical guides
set horizPos to {".25 in", "9.5 in"} --top 7 bottom horizontal guides
make guide with properties {location:(vertPos), orientation:vertical}
make guide with properties {location:(horizPos), orientation:horizontal}
end tell
end tell
Hi. Direct the guides locked statement to the guide preferences and eliminate the quotes around the ruler guide color. The guide location should not be a list; the orientation is already specified, so there is only one other coordinate available.
As always Marc thank you for your help. I tried what you suggested & change some code but obviously something is off. I’m having an error unlocking & deleting previous guides on the master pages. Please
tell application "Adobe InDesign CS4"
activate
set myDocument to document 1
tell view preferences of active document
--Set horizontal and vertical measurement units to inches.
set ruler origin to page origin
set horizontal measurement units to inches
set vertical measurement units to inches
end tell
--change margins of the master spread
set myMasterSpread to master spread 1 of myDocument
tell margin preferences of page 1 of myMasterSpread
-- page margins and columns.
set left to ".5" --outside
set top to ".5 in"
set right to ".75 in" --inside
set bottom to ".75 in"
end tell
--Page margins master page for the right-hand page.
tell margin preferences of page 2 of myMasterSpread
set left to ".5" --inside
set top to ".5 in"
set right to ".75 in" --outside
set bottom to ".5 in"
end tell
--create guides on master pages 1 & 2
--** currently not working
set myMasterSpread to master spread 1 of myDocument
tell guide preferences of page 1 of myMasterSpread
set guides locked to false
set ruler guides color to orange
--tell page 1 of myDocument
delete guides
make guide with properties {orientation:vertical, location:".25"}
make guide with properties {orientation:vertical, location:"7.6875"}
make guide with properties {orientation:horizontal, location:".25"}
make guide with properties {orientation:horizontal, location:"10.25"}
--end tell
tell guide preferences of page 2 of myMasterSpread
delete guides
make guide with properties {orientation:vertical, location:".25"}
make guide with properties {orientation:vertical, location:"7.6875"}
make guide with properties {orientation:horizontal, location:".25"}
make guide with properties {orientation:horizontal, location:"10.25"}
end tell
end tell
end tell
Everything not specifically directed elsewhere goes to the document, so I got rid of the confusing mydocument reference. This works:
tell application "Adobe InDesign CS3"'s document 1
activate
--Set horizontal and vertical measurement units to inches.
tell view preferences
set ruler origin to page origin
set horizontal measurement units to inches
set vertical measurement units to inches
end tell
--change margins of the master spread
set myMasterSpread to master spread 1
tell margin preferences of page 1 of myMasterSpread
-- page margins and columns.
set left to ".5" --outside
set top to ".5 in"
set right to ".75 in" --inside
set bottom to ".75 in"
end tell
--Page margins master page for the right-hand page.
tell margin preferences of page 2 of myMasterSpread
set left to ".5" --inside
set top to ".5 in"
set right to ".75 in" --outside
set bottom to ".5 in"
end tell
delete guides
--unlock/colorize
tell guide preferences
set guides locked to false
set ruler guides color to orange
end tell
--make
tell myMasterSpread's page 1
make guide with properties {orientation:vertical, location:0.25}
make guide with properties {orientation:vertical, location:7.6875}
make guide with properties {orientation:horizontal, location:0.25}
make guide with properties {orientation:horizontal, location:10.25}
end tell
tell myMasterSpread's page 2
make guide with properties {orientation:vertical, location:0.25}
make guide with properties {orientation:vertical, location:7.6875}
make guide with properties {orientation:horizontal, location:0.25}
make guide with properties {orientation:horizontal, location:10.25}
end tell
end tell
:D:D:D
Wow. I see all my errors. I get confused in how to addressed certain items. As you can see i use the code from other users but If i don’t try to write my own scripts I don’t learn. Once again Thank you
With that comes the question when to use MyDocument
You’re welcome. As a rule of thumb, I avoid variablizing anything for which I don’t see a later use or good reason, especially in InDesign, where you can easily make double references; I would probably never use a variable for the document. 
If you ever get to script InDesign Server, you’ll discover that one of the few differences is that it has no active document property. As active document simply returns a reference to document 1, it really is unnecessary.