Using Hook in Microsoft OneDrive with Microsoft Office Apps

As of Hook 3.1 ( Integration v. 168, 2021-05-25), if you open Microsoft Office files that are in OneDrive and then invoke Hook, you will get this message: No linkable item found in <App>, where <App> is Word, Excel or PowerPoint app.

To get around that you have two main options:

Option 1: disable OneDrive syncing, use hook://file/ always

You can disable OneDrive syncing in OneDrive Sync window. In OneDrive > Preferences> Office tab > File collaboration section: disable "Use Office application to sync Office files that I open"

See also Use Office applications to sync Office files that I open – Office Support.

This option will enable Hook to work in that context, and to use hook://file/ URLs rather than office specific URLs like this: [<filename>](ms-word:ofe%7Cu%7C

this also has the advantage that if you move the file out of OneDrive, the links will continue to work (you’re not locked into OneDrive). And Hook will use these same URLs in Finder. That is, whether you invoke Hook in Finder or the MS App, Copy Link will give you the same result, and therefore, you will see the same links ‘hooked’ to the document (if any).

However, if you need to keep OneDrive sync on all the time then consider the next two options.

Option 2: Keep sync on, but invoke Hook in Finder

Instead of invoking Hook in the Microsoft app, select the file in the Finder then invoke Hook. You can then paste the links anywhere. If you want to be able to navigate from the Office file in OneDrive to some other location, you can paste the other location’s URL in the document’s File > Properties > comments field. (Don’t rely on Finder comments, because OneDrive might not sync them.)

Option 3. Replace Hook’s Get Address with the following

If you really want to invoke Hook in Office for documents in OneDrive and get Microsoft specific URLs, then simply replace Hook’s Get Address script for the respective app with the following. The following is for Word. Do the same thing for the other MS Office apps if you like.

 tell application "Microsoft Word"
    set activeDoc to active document
    set activeDocName to name of activeDoc
    set activeDocPath to path of activeDoc
    set fullURL to posix full name of activeDoc
    if fullURL does not start with "http" then
        return "file://" & POSIX path of fullURL
    end if
end tell

set appURL to "ms-word:ofe|u|" & fullURL

Here’s how.

that script will return a hook://file/ or a MS specific URL, depending on what MS’s API returns. I.e., if the file is in OneDrive, OneDrive sync is on, and you invoke Hook in a MS Office app, you should get a MS specific URL.

Powerpoint script

Here is a Get Address script for Powerpoint that behaves in same way as the Word script above, returning a ms-powerpoint URL if needed.

tell application "Microsoft PowerPoint"
    set activeDoc to active presentation
    set activeDocName to name of activeDoc
    set activeDocPath to path of activeDoc
    set fullURL to full name of activeDoc
    if fullURL does not start with "http" then
        return "file://" & POSIX path of fullURL
    end if
end tell
set appURL to "ms-powerpoint:ofe|u|" & fullURL


Regarding Options 1 and 2: in our tests, if you rename OneDrive files directly on`,hook://file//` links to them will still work. That’s handy.

And of course, one would expect option 3 to lead to robust links, so long as the files are kept in OneDrive and OneDrive Sync is enabled.

Technical background

Hook connects with your favorite apps through their API (application programming interface). In particular, to construct a link, Hook asks the current app for the location and name of the foreground document. If you are using editing a file with a non Microsoft Office app, Hook will use whatever URL scheme it normally would. That will typically be a hook://file/ URL, which is valid in Dropbox, Finder, OneDrive, and many other local file storage systems.

Unfortunately, for files residing locally in a OneDrive folder, the location that Microsoft Office apps returns when Hook asks for their address depends on whether OneDrive is running or not. If OneDrive is running and OneDrive’s "Use Office application to sync Office files that I open" is enabled, Microsoft Office apps return a URL with an odd URL scheme. Otherwise, Microsoft Office apps return a typical file:// URL, which Hook converts to a hook://file/ URL.

For more information

For a discussion of this topic, visit Microsoft OneDrive Word Document Issues — Hook Productivity Forum

Hook Productivity App Newsletter

Sign-up to receive emails about Hook productivity app. Our emails sometimes include coupons for discounts on great Hook-linkable apps made by other developers.

 Marketing permission: I give my consent to to be in touch with me via email using the information I have provided in this form for the purpose of news, updates and marketing.

What to expect: If you wish to withdraw your consent and stop hearing from us, simply click the unsubscribe link at the bottom of every email we send or contact us at We value and respect your personal data and privacy. To view our privacy policy, please visit our website. By submitting this form, you agree that we may process your information in accordance with these terms.