PDF to Word

Hello, I am new to using Applescript and I am having some trouble writing a script to save a pdf as a word document in Adobe Acrobat Pro. The script I wrote so far finds the document and opens it. However, the apple script does not appear to recognize click action and I am not sure how to complete the apple script. Any suggestions?

tell application “Finder”
activate
open document file “Test Word.pdf” of folder “PDF to DOC” of folder “Desktop” of folder “jack” of folder “Users” of startup disk

end tell
tell application “Adobe Acrobat Pro”
tell application “System Events”
tell process “Adobe Acrobat Pro”
tell menu bar 1
tell menu “File”
tell menu item “Save As”
Click “Microsoft Document”
Click “Word Document”
end tell
end tell
end tell
end tell
end tell
end tell

Hi,

try this


set PDFDoc to (path to desktop as text) & "PDF to DOC:Test Word.pdf"
tell application "Adobe Acrobat Pro"
	activate
	open PDFDoc
end tell
tell application "System Events"
	tell process "AdobeAcrobat"
		click menu item "Word Document" of menu 1 of menu item "Microsoft Word" of menu 1 of menu item "Save As" of menu 1 of menu bar item "File" of menu bar 1
		repeat until exists window "Save As"
			delay 0.2
		end repeat
		click button "Save" of window "Save As"
	end tell
end tell


Worked great! Thank you!

@StefanK, how would one modify this (I’m using the version of Acrobat in the script) to open a folder of pdfs and convert them to .docx? Is it possible to also request a folder to save to?

I have this from trying to combine two scripts here, but it won’t compile. What am I doing wrong?

property Default_Location : (path to desktop as Unicode text) as alias
--
set Input_Folder to choose folder default location Default_Location with prompt "Select a folder of PDFs" without invisibles
--
tell application "Finder"
	-- Check to see if your folder is on the desktop else make one
	if not (exists (folder "pdf to docx" of Default_Location)) then
		make new folder at Default_Location with properties {name:"pdf to docx"}
	end if
	set Output_Folder to (folder "pdf to docx" of Default_Location) as text
	--
	set File_List to (files of Input_Folder whose name extension is "pdf")
	repeat with This_File in File_List
		set The_File to This_File as alias
		tell application "Adobe Acrobat Pro"
			activate
			open The_File
			set Doc_Name to name of document 1
			set Base_Name to my getBaseName(Doc_Name)
			set New_File_Path to Output_Folder & Base_Name & ".docx"
			end tell
			tell application "System Events"
	tell process "Acrobat"
		click menu item "Word Document" of menu 1 of menu item "Microsoft Word" of menu 1 of menu item "Save As" of menu 1 of menu bar item "File" of menu bar 1
		repeat until exists window "Save As"
			delay 0.2
		end repeat
		click button "Save" of window "Save As"
	end tell
end tell

You were missing two end statements.

One for a repeat loop and one for a tell statement.


property Default_Location : (path to desktop as Unicode text) as alias
--
set Input_Folder to choose folder default location Default_Location with prompt "Select a folder of PDFs" without invisibles
--
tell application "Finder"
	-- Check to see if your folder is on the desktop else make one
	if not (exists (folder "pdf to docx" of Default_Location)) then
		make new folder at Default_Location with properties {name:"pdf to docx"}
	end if
	set Output_Folder to (folder "pdf to docx" of Default_Location) as text
	--
	set File_List to (files of Input_Folder whose name extension is "pdf")
	repeat with This_File in File_List
		set The_File to This_File as alias
		tell application "Adobe Acrobat Pro"
			activate
			open The_File
			set Doc_Name to name of document 1
			set Base_Name to my getBaseName(Doc_Name)
			set New_File_Path to Output_Folder & Base_Name & ".docx"
		end tell
		tell application "System Events"
			tell process "Acrobat"
				click menu item "Word Document" of menu 1 of menu item "Microsoft Word" of menu 1 of menu item "Save As" of menu 1 of menu bar item "File" of menu bar 1
				repeat until exists window "Save As"
					delay 0.2
				end repeat
				click button "Save" of window "Save As"
			end tell -- was missing
		end tell
	end repeat -- was missing
end tell

@robertfern thanks! That did allow the script to compile. Thanks for your help.

New problem: When the script is running it’s creating a new script on the desktop called pdf to wordx as opposed to going to that folder. Additionally, after opening a couple of the files in Acrobat Pro, it stops with an error “«script» doesn’t understand the “getBaseName” message” from the line “set Base_Name to my getBaseName(Doc_Name)”

Can you help with that? Really appreciate you.

I can’t help due to I don’t have Acrobet Pro

Thanks, @robertfern.