So. You have a document open in what app?
Saved and synchronized to OneDrive?
And the macro doesn't work?
Do you have a local OneDrive folder and a OneDrive app? Or is Office reaching out on the net by itself?
I don't have MSO-365 to test with...
llity
March 23, 2022, 4:51am
22
The document was open with word.app. I have a local OneDrive folder and a OneDrive app.
Only the documents linked by Excel, PPT, and Word app in the onedrive, which cannot be revealed in the Finder.
Right-click the title bar, nothing happend.
Open a suitable test document in Word, and try running this in the Apple Script Editor.app .
See if you get an appropriate result:
tell application "Microsoft Word"
tell active document
set docPathPosix to its posix full name
end tell
end tell
return docPathPosix
llity
March 23, 2022, 5:21am
24
BernSh
March 23, 2022, 11:21am
25
tell application "TextEdit"
tell active document
set docPathPosix to its posix full name
end tell
end tell
return docPathPosix
Returns "Expected end of line but found class name."
Running Script Editor 2.11 in macOS 12.3
?
"Microsoft Word" ⇄ "TextEdit"
Each application provides its own osascript interface – they're not interchangeable.
1 Like
You might try this kind of thing:
tell application "TextEdit"
tell front document
path
end tell
end tell
or
tell application "TextEdit"
path of front document
end tell
1 Like
I'm not going to special-case it for Microsoft Office 365.
That macro uses AppleScript UI-Scripting to discover the document attached to the front window in the front application, and there are a few apps it won't work with.
That said – others are welcome to attend to their own special needs.
1 Like
llity
March 24, 2022, 1:29am
30
Thanks, tt's only not work with the documents stored in the OneDrive.
Works great for some apps.
"No file was associated with the front window!" for Logic Pro and Ableton Live.
As it says on the box in the first thread – neither macOS nor application developers allow for any universal methods, alas.
ccstone:
most applications.
1 Like
Hi @noisneil - for Logic there is the inbuilt menu item "Show in Finder" so, maybe you could add this in to the Macro with an If Then Action?
2 Likes
In this particular case, I was trying to get the name of the currently open Logic session, which I ended up just getting from the window title; didn't need the path after all.
Tried using @ccstone 's macro again today to help with this , with no joy. Of course, I didn't bother to read the macro notes this time, hence my pointless assertions.
1 Like
I have added a %FrontDocumentPath% token for the next version, based largely off this script (I hope that's fine with you Chris?).
8 Likes