copying and pasting in illustrator...... not so easy.....

Hi All,

I’m new to applescripting as well as new to this forum…

I’m stuck on a script i’m building that copies artwork from one file and pastes it in exactly the same place from where i copied it from into another file.

I have got illustrator to copy and paste the items into another document but when a paste them they are in a slightly different postition. (By the way the two files i’m testing the script from are copies of the same document so the position of the artwork in the paste board are the same.) If i did this manually using the paste in front command (apple + F Keys) the artwork pastes in perfectly. But i can’t get applescript to do the same.

But if i open the file in illustrator before i run the script and click on the ‘Fit In Window’ command, and then run the script it will work!!! but i can’t get applescript make illustrator do this command as there seems nothing regarding this in dictionary…

Sorry about the long message, if someone knows how to solve this or any ideas of getting round this i would much appreciate it.



have you tried / thought of the UI scripting concept for this should if you adapt this to you script correctly
don’t forget to turn on UI scripting (Applescript Utility)

tell application "System Events"
	tell application process "App"
		tell window "blah"
			keystroke "F" using command down
		end tell
	end tell
end tell

This is pretty generic, but this puts everything in the exact same position as the original. Don’t know if you can use this or not, but here it is.

tell application "Illustrator CS"
	set rulerO to ruler origin of current document
	set h to height of current document
	set w to width of current document
	make new document with properties {height:h, width:w}
	set ruler origin of current document to rulerO
	duplicate every page item of document 2 to document 1
end tell


I’ve got it working perfectly now. I used the UI scripting to set the page to fit the window before i pasted the artwork into the new document.

Thanks alot!!!