Trying to overwrite an exisiting pdf file

Hello. I’m hoping someone can help me get past this problem. When i have a pdf document open and run this script, it gets all the way to the “existing file do you want to overwrite” dialog box, but will not click the “Replace” button. Anyone have any ideas or suggestions? Thanks.

activate application “Adobe Acrobat Professional”

tell application “System Events”
tell process “Acrobat”
delay 1
keystroke return
click menu item “Enable Usage Rights in Adobe Reader…” of menu 1 of menu bar item “Advanced” of menu bar 1
delay 1
keystroke return
delay 1
keystroke return
delay 1
keystroke return
delay 1
click button “Replace” of front window

end tell

end tell

Hi,

try this

activate application "Adobe Acrobat Professional"
tell application "System Events"
	tell process "Acrobat"
		click menu item "Enable Usage Rights in Adobe Reader..." of menu 1 of menu bar item "Advanced" of menu bar 1
		tell window 1
			repeat until exists button "Save Now"
				delay 0.5
			end repeat
			click button "Save Now"
			repeat until exists button "Save"
				delay 0.5
			end repeat
			click button "Save"
			repeat until exists button "Replace"
				delay 0.5
			end repeat
			click button "Replace"
		end tell
	end tell
end tell

Thanks. The repeat until replace exists really helped me out.