gglick
June 6, 2019, 9:51am
14
I'm not Chris (obviously ) but I think I can answer this nonetheless; I'm afraid you did guess wrong. The macros and scripts in this thread are for obtaining the file path for the frontmost document in apps other than the Finder, and can't be used to get the current Finder selection. Fortunately, there's only one KM action needed to get the path of the file currently selected in Finder, For Each:
Just select that collection, and the variable specified in the "For each" field will contain the path to the selected file once the macro is run.
2 Likes
llity
August 16, 2019, 6:13am
15
It is not work for me, it showed "No file was associated with the front window!" when i open word file with office.
ccstone
August 27, 2019, 12:31am
16
Hey Liang,
It works fine for me with Word from Office 2016 – IF the front document has already been saved.
If the front document is not saved then it behaves as you describe above.
-Chris
llity
March 3, 2020, 4:51am
17
Thanks, now it's work fine!
llity
March 23, 2022, 1:49am
18
Doesn't work with the documents synchronized by OneDrive.
You said otherwise here:
So, did you get it to work or not?
llity
March 23, 2022, 4:21am
20
It's still not work for the office document synchronized by onedrive. And these file cannot reveal by right-click the title bar.
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