Microsoft OneDrive Word Document Issues [Solution: quit OneDrive, relaunch the MS App]

I have started using Hook this week and see enormous value in this. I’m hooked (excuse the pun).

However, there is one use case here that is causing me issues. I’m wanting to hook a Microsoft Word document that is stored in my OneDrive folder which is obviously synchronised with Microsoft cloud services. When I try and create hook to any Word document stored in One Drive, Hook is unable to do so stating “No item detected in Microsoft Word”. I don’t believe this is a One Drive issue per se as Excel spreadsheets stored in One Drive work fine. I also don’t think it is a cloud storage / synch issue as Word documents stored on Apple iCloud folders also work fine. Issue seems to be confined to Word documents stored in Microsoft One Drive and Sharepoint repositories.

Anybody else found this behaviour?

Cheers

Is it the Word files or the Word app? I suspect it would be the latter and you should be able to select the Word file in Finder to link it while the app isn’t working as expected.

Thanks @stevelw. It is the file itself and not the app. However, as you suggested, linking to it directly in Finder does work so that is good enough for me now. Much appreciated.

It doesn’t however, allow me to copy a link from directly within the open Word doc file still. But I can live with that knowing I can link via Finder.

Cheers

I’ve just tried this on my system and can confirm this is an issue.

Word, Excel, and PowerPoint all work as expected with files in normal folders.

Word documents in OneDrive folder don’t work from within the Word app, but Excel and PowerPoint continue to work as expected.

Thanks for confirming Steve. Glad to know it’s not specific to me. Hopefully can get recognised as a bug and addressed now.

Cheers
Dean

Thanks for the problem report and the replication.

At my end, I was not able to replicate with Hook Version 1.0-beta (2372, and later internal builds) , under macOS Mojave (10.14.5) using OneDrive v 19.062.0331.0010 (from App Store) and Word Version 16.16.10.

Could you please confirm your macOS version, OneDrive version (app store?) and MS Word ?

I’ve now managed to replicate the problem by turning on the One Drive > Office> “Use Office applications to sync Office files that I open” setting. When I turn that off, the Hook Window is properly populated.

We’ll investigate.

Also, @LucB, I am running the same version of OSX and Hook, but my version of OneDrive is 19.070.0410.0007 in case that’s of any relevance to you. Although I doubt it, given you can replicate the issue now in any case.

Thanks.

correct, it’s not a version issue.
When Office sync is enabled, Word returns an abnormal https “path” , e.g., something like https/::d.docs.live.net:q7s94-1g266:test comments:abc.docx, instead of a file URI.

I know this is an old thread, but was this resolved? I’m still running into this issue with open word docs that are stored in a shared OneDrive folder.

Thanks,
Greg

Same here. I wonder if there’s a way to tie both this https URL and a file:// reference to the local file on Hook’s database.

Disabling the Office sync feature is a problem when working with colleagues with shared files.

Same here - would be great if this could be resolved @LucB

After some further investigation, I’ve come to realize that the string returned from Word, PowerPoint and Excel can be changed into a file:/ link format with some AppleScript.

Those strings are alongside this format
https://some.company-my.sharepoint.com/personal/some.user/Documents/ followed by the relative path to the corresponding file.

If we change the first part of the link to the path to OneDrive (such as file:///Users/lucas/OneDrive - Some Company) and keep the relative path, we can reach the local file and have hook link to it just fine.

I’ve wrote a few lines of code to replace those with the path to my OneDrive root folder and now it’s working fine.

Sharepoint folders required with a few other tweaks on the strings, but worked the same.

Would you care to share the Applescript you used?

1 Like

Sure, it’s very ugly but gets the job done.

You’ll need to replace the strings on Step 1 for them to match your setup and also create/delete some else if statements on Step 3 accordingly.

There are a few comments on the code to help you along the way.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

-- 1. Sets the strings for search and replace. I took tree sets for me as I sync  one OneDrive and two Sharepoint shared documents folders

-- A. My Personal OneDrive
set stringODL to "https://company-my.sharepoint.com/personal/myuser/Documents/"
set newStringODL to "file:///Users/user/OneDrive - Company/"

-- B. Sharepoint Shared Documents folder tor Team 1
set stringTeam1 to "https://company.sharepoint.com/sites/team1/Shared Documents/"
set newTeam1 to "file:///Users/user/Company/Team1/"

-- C. Sharepoint Shared Documents folder tor Team 2
set stringTeam2 to "https://company.sharepoint.com/sites/Team2/Shared Documents/"
set newStringTeam2 to "file:///Users/user/Company/Team2/"


-- 2. Fetches the full name property for the current opened file (a full path)
tell application "Microsoft Word"
	set originalURL to full name of active document
	-- If you open a local file that is not on an OneDrive nor Sharepoint folder, then the full path will not start with https
	if originalURL does not start with "https" then
		set originalURL to POSIX path of originalURL
	end if
end tell

-- 3. Find and Replace: will look for the initially defined strings and replace them with the provided new paths

-- 3.1. Will use this handler from Find and Replace in AppleScript from Stack Overflow (https://stackoverflow.com/questions/28115085/find-and-replace-in-applescript)
on replaceText(find, replace, subject)
	set prevTIDs to text item delimiters of AppleScript
	set text item delimiters of AppleScript to find
	set subject to text items of subject
	
	set text item delimiters of AppleScript to replace
	set subject to subject as text
	set text item delimiters of AppleScript to prevTIDs
	
	return subject
end replaceText


-- 3.2. The if statements for replacing the beggining of the path to the defined variables on Step 1
if originalURL starts with stringODL then
	set newURL to replaceText(stringODL, newStringODL, originalURL)
else if originalURL starts with stringTeam1 then
	set newURL to replaceText(stringTeam1, newTeam1, originalURL)
else if originalURL starts with stringTeam2 then
	set newURL to replaceText(stringTeam2, newStringTeam2, originalURL)
else
	-- If the originalURL variable is already a local path, it should begin with "/Users" so it will just preppend a file:// to the originalURL
	originalURL starts with "/Users"
	set newURL to "file://" & originalURL
end if

return newURL
1 Like

Thanks for reviving this topic and providing a fix! We will revisit too. Some of our current integration ToDos are on Twitter.

Thanks for the script. I have amended it for my file locations and tested the script within script editor and it works perfectly. however, when I copy the script to Get Address within Hook preferences, I still does not seem to work. When I invoke Hook, I get no linkable item found in Hook. Any suggestions?

@ranger, @ldebritto , @mdbraber :
A work-around quite a while later after the OP is Quit OneDrive, relaunch the MS app. Microsoft’s AppleScript API seems to behave differently depending on whether OneDrive is running.

We ( CogSci Apps Corp.) are still interested in providing some URL unification here (i.e., the resource has multiple URLs), as we’ve discussed in other contexts.

Hey Luc – I just found this thread after seeing the other threads about the issue.

The ability to get the link from Excel here, which Idebritto mentions sounds really cool; could this be used by Hook to link to the URL of that documenbt (in the same way you could do if you were actually visiting a web page)?

Tom