pdf to Word via Acrobat X

I’m trying to compile two older scripts to do this but it throws an error at the compile stage. Wanting to pick a folder of pdfs, then use Acrobat X to convert them to Word and pick a folder for those .docx files to be saved to.

I’m a horrible programmer and stuck at the script not compiling.

Any help appreciated. (Sorry for the double post but the original was attached to a 7 yo one.



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

Was this resolved in the other thread? If not, the script you posted compiled for me when I switched to “Adobe Acrobat” from “Acrobat Pro” (It should compile for you if you switch back)

The compile errors I got were that it was missing and “end.” When that happens, you can usually type “end” and return at the end of your script and try to compile again. I think I had to add two ends.

Sometimes you may need to change an “end if” “end return” or “end tell” or some other type of end to just “end” and let the compiler fill in the missing term.

A not of caution though, whenever you do this you need to take an extra look at your script and make sure all your tell blocks, etc. are ending at the right place.

HTH

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"
         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
   end repeat
end tell
 

@estockly: In the other thread @robertfern made the same missing end corrections you did. On my system Adobe Acrobat Pro is correct as that is what Adobe Acrobat X is. 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.

OK, try something like this. The “Finder” tell block wasn’t closed when your finder calls were done. Plus I didn’t like the way the output folder was being assigned so I changed that. But, I don’t have Acrobat Pro, so I can’t test that part of the script here.

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
--
set outputFolderName to "pdf to docx"
tell application "Finder"
	set Output_Folder to (Default_Location as text) & outputFolderName & ":"
	
	if not (exists (folder Output_Folder)) then
		set Output_Folder to make new folder at Default_Location with properties {name:outputFolderName}
	end if
	set Output_Folder to Output_Folder as text
end tell

   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"
         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
   end repeat
 

@estockly: Thanks so much for helping. This is a huge project for me. Hopeful, it will come to resolution. Now, getting this error:
"error “Can’t get every file of alias "Crucial SSD:Users:deh:Downloads:Apps:Unclutter:Nimbus Notes — 20220601:export-2022-06-006_12-30-59:All Notes:Beer & Other Drinks:".” number -1728 from every file of alias “Crucial SSD:Users:deh:Downloads:Apps:Unclutter:Nimbus Notes — 20220601:export-2022-06-006_12-30-59:All Notes:Beer & Other Drinks:”

This is new. Haven’t seen this before. Might it have anything to do with “every file of alias”? (Was gonna post a screenshot of the error, but I guess we can’t post images?