Use Automator to save to PDF Office 365 Word documents

This is a reply to this post :

https://discussions.apple.com/thread/250067807?answerId=250118986022#250118986022


I use the following modified automator AppleScript service to batch convert .docx in PDF with office 365 (January 2022):


this script was written by VikingOSX, I've updated it to match service requirement


property Delim : {".docx", ".doc"}
property PDF : ".pdf"

on run {selected_files, parameters}
	
	set outPDF to {}
	-- replace Word document extensions with PDF, and append to outPDF list
	set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, Delim}
	repeat with afile in selected_files
		copy item 1 of text items of (afile as text) & PDF to the end of outPDF
	end repeat
	set AppleScript's text item delimiters to TID
	
	tell application id "com.microsoft.Word"
		activate
		repeat with i from 1 to count of selected_files
			open (item i of selected_files)
			set theOutputPath to (item i of outPDF)
			-- close access (open for access exportDocument)
			tell active document
				save as it file name theOutputPath file format format PDF
				close saving no
			end tell
		end repeat
	end tell
	return
end run

Posted on Jan 30, 2022 11:28 PM

Reply
1 reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Use Automator to save to PDF Office 365 Word documents

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.