File Selection and GUI Scripting - stuck!

I have a list of files that have been set to a variable in the Finder application. During a GUI scripting process in PowerPoint that involves a repeat loop, the file browser is opened within PowerPoint and one of the files from the list needs to be re-selected, or “clicked.”

I don’t believe there is a way to click the the file with GUI so my question is: how do I reference the target file?

I managed to resolve this issue in this manner:



set sourceFolder to choose folder
tell application "Finder"
	set theFiles to files of sourceFolder whose name extension is in {"pptx", "ppt"}
end tell
tell application "Microsoft PowerPoint"
	open item 1 of theFiles
	
	repeat with i from 2 to (count theFiles)
		tell application "Finder"
			set posixPath to POSIX path of nextFile
		end tell

tell application "System Events"
			tell process "Microsoft PowerPoint"
				click menu item "Other Presentation..." of menu 1 of menu item "Slides From" of menu 1 of menu bar item "Insert" of menu bar 1
				keystroke "G" using {command down, shift down}
				delay 0.2
				set value of text field 1 of sheet 1 of window "Choose a File" to posixPath
				delay 0.2
				keystroke return
.....


One caveat - this works only with Powerpoint 2008! In Powerpoint 2004, the “go to folder” does not accept the posix path. In fact, if you try to open a file, and choose cmd+shift+g, enter the path, the file is not showing up in the browser. Perhaps a glitch in Office 2004. I’d be interested to see if others see this same issue and possibly offer a workaround.