It's becoming clear to me that VBA does not handle file operations with Sharepoint/OneDrive very well. I have the following code:
Sub TestSaves()
Dim fName, fNameNoEx, SaveName As String
Dim fldr As FileDialog
CurrPath = ActiveDocument.Path
'CurrPath = "C:\temp"
If Left(CurrPath, 4) = "http" Then
PathSep = "/"
Else
PathSep = "\"
End If
FileNumber = FreeFile
OutputFile = CurrPath & PathSep & "fred.txt"
MsgBox OutputFile
Open OutputFile For Output As #FileNumber
Print #FileNumber, "Hello World"
Close #FileNumber
End Sub
When my CurrPath = ActiveDocument.Path
is active, I get a run-time error 52 (bad file name or number). In thise case, CurrPath looks like:
When my CurrPath = "C:\temp"
is active, it works fine.
I'd like to be able to save another file in the same location as the original document, regardless of whether it's local or on OneDrive/Sharepoint. Any suggestions?