Gui Scripting Word

I am using Powerpoint 2004 with Tiger and trying to select a file using cmd+shift+g during a specific process. Somehow the “go” button does not activate until I maually click in the text field, delete the last character and retype the character.

Here is the code:



set posixPath to "/Users/Marlon/Desktop/ppt/1.ppt"
tell application "Microsoft PowerPoint"
	activate
	tell application "System Events"
		tell process "Microsoft PowerPoint"
			click menu item "Slides from File..." of menu 1 of menu bar item "Insert" of menu bar 1
			delay 0.2
			keystroke "g" using {command down, shift down}
			delay 0.2
			set value of text field 1 of window 1 to posixPath
			delay .2
			click button "Go" of window 1 ----->>> the "go" button does not highlight even though the path is correct
			delay 0.2
		
		end tell
	end tell
end tell

I don’t know if this is a glitch in Tiger. Somehow, this script works for SN and PowerPoint 2008

Hi,

the main problem is, the text field and the button Go belong to sheet 1 of window 1, not directly to window 1.
With GUI scripting it’s always recommended to use controlled delays by waiting for particular Ui elements


set posixPath to "/Users/Marlon/Desktop/ppt/1.ppt"
tell application "Microsoft PowerPoint"
	activate
	tell application "System Events"
		tell process "Microsoft PowerPoint"
			click menu item "Slides from File..." of menu 1 of menu bar item "Insert" of menu bar 1
			repeat until exists button 5 of window 1 -- waits for the open/save window
				delay 0.2
			end repeat
			keystroke "g" using {command down, shift down}
			tell window 1
				repeat until exists sheet 1
					delay 0.2
				end repeat
				tell sheet 1
					set value of text field 1 to posixPath
					click button "Go"
				end tell
			end tell
			delay 0.2
		end tell
	end tell
end tell


Hello,

The modification to the script did not work. I checked whether the cmd+shift+g is giving a window or a sheet and from Prefab’s UI Browser, I am seeing only another window. Also, I confirmed this was not a sheet by getting a false return of the sheet in events log ( I ran the repeat look for sheet 1).

I got the script to work by simply replacing the “set value of text field of window 1 to posixpath” to “keystroke posixpath” and viola!

Stefan, I have finally read Hanaan’s book (with the except of 3 chapters) and now feel more confident with AS. Nothing beats education! Thanks for the suggested reading and have a wonderful Fall season. Oktoberfest around the corner, no?