Anyone remember double-tells?

Anyone remember that techniqe where you can move your scripts to new machines without having the script ask the user to locate an application the first time they run it?


	-- Word should be runnning now!
	tell application "Finder" -- let's see...
		set appName to name of application file id "MSWD"
	end tell
	
	tell application "Microsoft Word"
		tell application appName
			close documents without saving
			if exists document "document1" then
				close document "document1" without saving
			end if
		end tell
	end tell

… gets you this event log


tell application "Finder"
	get name of application file id "MSWD"
		"Microsoft Word X v3"
end tell
tell application "Microsoft Word"
	close document "temp.txt" of application "Microsoft Word X v3" saving no
		"Microsoft Word got an error: Can't get document \"temp.txt\" of application \"Microsoft Word X v3\"."

Can anyone tell me how to word the “close document “document1” without saving” line so it doesn’t get interpreted as referring to “of Microsoft Word X v3”?

OX X 10.4, AS 1.10, Will run with multiple versions of word X

Thanks!

Browser: AS 1.10
Operating System: Mac OS X (10.4)

Instead of the old double-tell, try a ‘using terms from’ block instead. This was introduced to allow a script to be compiled with the appropriate application terms - and should avoid the confusion between two different applications being told to execute the same routine.

Obviously, any terms used need to be common to both the app enlisted to compile the application-specific statements (in this case, “Microsoft Word”) and the one that will execute them at run time (appName ”> “Microsoft Word X v3”).

using terms from application "Microsoft Word"
	tell application appName
		
		(* application-specific statements here *)
		
	end tell
end using terms from

Thanks kai! I kind of had a feeling that was it, but I didn’t know it way that easy.