I have a text file which stores the next available invoice number for my Excel spreadsheet. It has worked for years, but when I try to make it more flexible (there are more users accessing this from different computers), I am running into a problem.
Currently I have a button which I click to choose the path to the text document. This opens a file dialog box (msoFileDialogFilePicker). I have also included a custom function which will determine the UNC path, to accommodate different users on different computers. The problem occurs when the path that I choose is a mapped network drive to OneDrive. It seems to get stalled when it tries to open a file which contains “https://” in its path.
The code that I am using looks something like this:
Dim intInvoiceNumber As Integer
Dim strFullName As String
strFullName = Sheet999.Range(“TextUNC_FullName”) ‘defined range in Excel which contains the full path
Open strFullName For Input As #1
Input #1, intInvoiceNumber
Close #1
Open strFullName For Output As #2
Write #2, intInvoiceNumber + 1
Close #2
This OneDrive path works: \\COMPUTER_NAME\Users\USER_NAME\OneDrive\FILE_NAME.txt Of course, everything shown in capital letters is substituted here for the actual name.
This mapped OneDrive path does NOT work: https://d.docs.live.net/SOME_NUMBERS/FILE_NAME.txt Again, the capital letters are substituted for the actual path and/or name.
How can I modify this code to accommodate users who choose the mapped network path? I suspect it might be the forward slash, but I don’t know how to deal with it.
Bookmarks