[Apple Script Help] Open the folder of current document

Hi all,

I am trying to create a KM script that would open the folder in which the current word document I'm working on is in.

This is what I wrote:

tell application "System Events"
	tell application "Microsoft Word"
		set thefile to path of the front document
		tell application "Finder"
			open thefile
			set frontmost to true
		end tell
	end tell
end tell

However, this script doesn't work when I have multiple documents open, it will always open the finder folder of the first document I opened instead of the document I'm currently looking at (frontmost). Is there anything I am doing wrong?

Thanks

Hi and welcome to the forum! :wave:t3:

Keyboard Maestro 11 comes with a new token that simplifies this:

2 Likes

Oh my god this does exactly what I was trying to achieve! Thank you!

1 Like