Forum Discussion
Word 365 attached template from Onedrive shows URL instead of path
Thanks for your suggestions.
I just remembered that my files were copied directly from the File Explorer to a mapped OneDrive-folder instead of synching them from SharePoint. These directly copied files are working fine.
To be sure I am working with a proper environment, I completely removed OneDrive from my computer, re-installed it and synch'd again. Now, I am facing the same problem as my client (which is 'good ' :-) )
Then, I have checked your suggestions:
1. I have hard coded the path (both the local Onedrive-mapping as the SharePoint-URL), but the result is the same: Word cannot find or read the text file.
2. The files are indeed synch'd to the computer and I have the correct permissions
I think I need a checkbox where Word/Windows accepts the mapped OneDrive folder name … Any ideas?
Thx, José
José Spanjaard You can pick up the current user's local OneDrive folder path from the registry, using code like this:
Dim myWS As Object
Function RegValueExists(i_RegKey As String) As Boolean
On Error GoTo ErrorHandler
'try to read the registry value
myWS.RegRead i_RegKey
'value was found
RegValueExists = True
Exit Function
ErrorHandler:
'key was not found
RegValueExists = False
End Function
Function RegValueRead(i_RegKey As String) As String
On Error Resume Next
'read value from registry
RegValueRead = myWS.RegRead(i_RegKey)
End Function
Sub testOneDrive()
Dim strOneDriveKey As String
Dim strOneDriveFolder As String
strOneDriveKey = "HKEY_CURRENT_USER\Software\Microsoft\OneDrive\UserFolder"
On Error Resume Next
'access Windows scripting
Set myWS = CreateObject("WScript.Shell")
If myWS Is Nothing Then
MsgBox "Could not access scripting shell"
Exit Sub
End If
If RegValueExists(strOneDriveKey) Then
strOneDriveFolder = RegValueRead(strOneDriveKey)
End If
If strOneDriveFolder <> "" Then
MsgBox strOneDriveFolder, vbInformation, "OneDrive User Folder"
Else
MsgBox "Folder not found", vbExclamation, "OneDrive User Folder"
End If
End Sub