Must Have Hazel Rules

I use an applescript with microsoft word:

tell application "Microsoft Word" to set theOldDefaultPath to get default file path file path type documents path 

-- looks like we change the default path to where the document is and then set it back when we're done

try
tell application "Finder"
	set theFilePath to container of theFile as text
	
	set ext to name extension of theFile
	
	set theName to name of theFile
	copy length of theName to l
	copy length of ext to exl
	
	set n to l - exl - 1
	copy characters 1 through n of theName as string to theFilename
	
	set theFilename to theFilename & ".pdf"
	
	tell application "Microsoft Word"
		set default file path file path type documents path path theFilePath
		open theFile
		set theActiveDoc to the active document
		save as theActiveDoc file format format PDF file name theFilename
		close theActiveDoc
	end tell
	
end tell

end try
try

tell application "Microsoft Word" to set default file path file path type documents path path theOldDefaultPath	
end try
3 Likes