Open Finder window in same path as active document (Office document)

It’s easy to google scripts that opens a new Finder window in a specific path, that opens a new Finder in the same path as a current Finder window, etc. What I’m looking for is to open a Finder window in the same path as the active document. The reason for this is Microsoft Office. With all other applications I have installed, I can always right click on the file name in the application toolbar, and from the dropdown menu I can click on the folder where the file is located. However, this isn’t possible with Microsoft Office when the files are stored in ~/OneDrive.

macOS should still be aware of where this file is located, right? It’s within my ~/ folder. Is it possible for an applescript to open the folder for where the current Office document is saved?

Microsoft Office isn’t application. It is container for applications. I can show you how to deremine the location with certain application. For example, with “Microsoft Excel” you can use this:


tell application "Microsoft Excel" to tell front document
	set theFolderPath to its path
	set theFilePath to its full name
end tell

tell application "Finder" to open (theFolderPath as POSIX file)

return {theFolderPath, theFilePath}