Print as PDF to DT from PowerPoint error

Dear All,

I’m trying to store a PowerPoint document in my DT Pro database by using Print --> PDF --> Save to DevonThink Pro.scpt.

However, on a lot of PowerPoint documents I get the error The variable this_name is not defined - it looks like this:
Picture 1.png

The version of PowerPoint is 2008. Has anyone an idea of what might be causing this? I did try the Help menu --> Install Add-ons… to see if reinstalling would do any good.

Any suggestions gratefully received.

Toby.

Did a dialog appear to enter the name? Or did the script immediately fail?

No, no intermediate dialog box appeared I’m afraid.

Does this script work?



on open these_items
	set this_app to (path to «constant afdregfp» as string)
	if this_app does not contain "DEVONthink Pro" then
		try
			set this_file to item 1 of these_items
			
			try
				tell application this_app to set this_name to the name of window 1
				if not (exists this_name) then error
			on error
				set this_name to ""
			end try
			
			tell application "DEVONthink Pro"
				activate
				if not (exists current database) then error "Please open a database before using this script!"
				repeat while this_name is ""
					display dialog "Saving to DEVONthink Pro. Please enter a file name:" default answer this_name
					set this_name to the text returned of the result
				end repeat
				set theDestination to display group selector "Destination" buttons {"Cancel", "OK"}
				set theRecord to import this_file to theDestination
				try
					set the name of theRecord to this_name
				on error
					error "Import failed."
				end try
			end tell
			
			try
				if this_app contains "Safari.app" then
					tell application "Safari" to set this_URL to the URL of document 1
					tell application "DEVONthink Pro" to set the URL of theRecord to this_URL
				else if this_app contains "Mail.app" then
					tell application "Mail"
						set theSelection to the selection
						set this_sender to the sender of item 1 of theSelection
					end tell
					tell application "DEVONthink Pro" to set the URL of theRecord to this_sender
				else
					tell application this_app
						set curr_doc_path to path of document 1
						if (curr_doc_path is not missing value) and (length of curr_doc_path > 1) then
							set doc_url to "file://" & (POSIX path of curr_doc_path)
							tell application "DEVONthink Pro" to set the URL of theRecord to doc_url
						end if
					end tell
				end if
			end try
			
		on error error_message number error_number
			if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
		end try
		tell application this_app to activate
	end if
end open

A silly question possibly, but how do I test the script that you kindly provided?

Open Apple’s Script Editor, paste the code and save the script to ~/Library/PDF Services/. Then try to print from PowerPoint and select the saved script.

Dear Christian,

Belated thanks for this. :smiley: I have been away for some time and with the holidays only got try this out just now. It seems to work in cases which throw the error above with the included script. The only difference I can see (apart from it working!) is that this one prompts me for a file name - is there any way around this?

Best,

Toby.