cristianbuse / VBA-FileTools

Useful methods for interacting with the file system
MIT License
87 stars 25 forks source link

.mountPoint = BuildPath(mainMount, cFolders(folderID) & "/") #15

Closed dcircleinc closed 1 year ago

dcircleinc commented 1 year ago

Get an error in the below line, on one specific computer, Excel 365 Windows 10.

.mountPoint = BuildPath(mainMount, cFolders(folderID) & "/")

errorLibTools

cristianbuse commented 1 year ago

Hi @dcircleinc ,

Thank you for the feedback!

Would you please be able to give me more details? For example if you replace this line:

.mountPoint = BuildPath(mainMount, cFolders(folderID) & "/")

with:

On Error Resume Next
.mountPoint = BuildPath(mainMount, cFolders(folderID) & "/")
If Err.Number <> 0 Then
    Debug.Print "lineText:", lineText
    Debug.Print "relPath:", relPath
    Debug.Print "folderID:", folderID
    Debug.Print "coll is init:", Not cFolders Is Nothing
    Debug.Print "coll count:", cFolders.Count
    Err.Clear
    cFolders folderID
    Debug.Print "key exists:", Err.Number = 0
    Debug.Print "mainURL:", mainURL
    Debug.Print "cID:", cID
    Debug.Print "webPath:", .webPath
    On Error GoTo 0
    Err.Raise 5
End If
On Error GoTo 0

and then copy the results from the Immediate window and paste them here, that would be very useful. For example:
image

dcircleinc commented 1 year ago

Here it is, the only thing I can see that maybe looks to be an issue is the "!" in the folderID? 

lineText:     57E95D7F0919FE4!2755_Path = Desktop/CASH SHEETS IN HERE

relPath:      Desktop/CASH SHEETS IN HERE

folderID:     57E95D7F0919FE4!2755

coll is init: True

coll count:    1

key exists:   False

mainURL:      https://d.docs.live.net/

cID:          51207bab5645f68f

webPath:      https://d.docs.live.net/51207bab5645f67e/Desktop/CASH SHEETS IN HERE/

Ryan Taliercio

---- On Tue, 06 Jun 2023 04:51:42 -0400 Cristian Buse @.***> wrote ---

Hi https://github.com/dcircleinc ,

Thank you for the feedback!

Would you please be able to give me more details? For example if you replace this line:

.mountPoint = BuildPath(mainMount, cFolders(folderID) & "/")

with:

On Error Resume Next .mountPoint = BuildPath(mainMount, cFolders(folderID) & "/") If Err.Number <> 0 Then Debug.Print "lineText:", lineText Debug.Print "relPath:", relPath Debug.Print "folderID:", folderID Debug.Print "coll is init:", Not cFolders Is Nothing Debug.Print "coll count:", cFolders.Count Err.Clear cFolders folderID Debug.Print "key exists:", Err.Number = 0 Debug.Print "mainURL:", mainURL Debug.Print "cID:", cID Debug.Print "webPath:", .webPath On Error GoTo 0 Err.Raise 5 End If On Error GoTo 0

and then copy the results from the Immediate window and paste them here, that would be very useful. For example: https://user-images.githubusercontent.com/23198997/243637133-7817cd92-42a3-4577-be54-6a3d442a81cc.png — Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1578219218, or https://github.com/notifications/unsubscribe-auth/AAHBDFY5WB4CNVFDIN2LEQTXJ3VR5ANCNFSM6AAAAAAY3M4NDU. You are receiving this because you were mentioned.

cristianbuse commented 1 year ago

Thanks @dcircleinc ,

I can see what the problem is. The folder count (coll count) cannot possibly be just 1 as surely you have more than 1 folder in your Personal OneDrive. What this means is that the algorithm in the GetODDirs method cannot find the folders as most likely you have a different byte configuration for the dat file. The method reads all the bytes and then searches for folder headers (hex x02 followed by x01000000).

Could you please change the line:

For stepSize = 16 To 8 Step -8

to:

For stepSize = 8 To 8 Step -8

and try again to see if it works. Thanks!

dcircleinc commented 1 year ago
        Thank you I will try this - will this negatively m affect other systems using this modified code or will it continue to work on those if I modify? Ryan Taliercio    ---- On Tue, 06 Jun 2023 13:16:14 -0400  ***@***.******@***.***> wrote ----  

Thanks @dcircleinc , I can see what the problem is. The folder count (coll count) cannot possibly be just 1 as surely you have more than 1 folder in your Personal OneDrive. What this means is that the algorithm in the GetODDirs method cannot find the folders as most likely you have a different byte configuration for the dat file. The method reads all the bytes and then searches for folder headers (hex x02 followed by x01000000). Could you please change the line: For stepSize = 16 To 8 Step -8 to: For stepSize = 8 To 8 Step -8 and try again to see if it works. Thanks!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

cristianbuse commented 1 year ago

Hi @dcircleinc ,

The changes I suggested are just temporary. For now, I just want to figure out what is going on. Once I do, I will push a new commit to cover old and new cases so you will need to replace the whole module at some point.

dcircleinc commented 1 year ago

Unfortunately, I got the same error when I changed that line. On the other computers, the code no longer executed like it previously did and didn't find the folder. I reverted back to the original code, and it works on the other computers, but gives the same error on the one in question.  

Ryan Taliercio

---- On Tue, 06 Jun 2023 13:16:14 -0400 Cristian Buse @.***> wrote ---

Thanks https://github.com/dcircleinc ,

I can see what the problem is. The folder count (coll count) cannot possibly be just 1 as surely you have more than 1 folder in your Personal OneDrive. What this means is that the algorithm in the GetODDirs method cannot find the folders as most likely you have a different byte configuration for the dat file. The method reads all the bytes and then searches for folder headers (hex x02 followed by x01000000).

Could you please change https://github.com/cristianbuse/VBA-FileTools/blob/feb2a11a917616b888e275ce385fec0e456c4f5a/src/LibFileTools.bas#L2288:

For stepSize = 16 To 8 Step -8

to:

For stepSize = 8 To 8 Step -8

and try again to see if it works. Thanks!

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1579159594, or https://github.com/notifications/unsubscribe-auth/AAHBDF4RQH2AYFCJZZVQ5HDXJ5QV5ANCNFSM6AAAAAAY3M4NDU. You are receiving this because you were mentioned.

cristianbuse commented 1 year ago

Thanks for testing. It seems that the dat file on that particular computer has some other type of convention that I haven't seen before. It would be great if you could send me the dat file for me to have a look at. The dat file only contains the folder and the file names but no information about the account or any other web setting - if you are happy to send it over then just paste it here under a new comment.

You can find the path by replacing the previous:

On Error Resume Next
.mountPoint = BuildPath(mainMount, cFolders(folderID) & "/")
If Err.Number <> 0 Then
    Debug.Print "lineText:", lineText
    Debug.Print "relPath:", relPath
    Debug.Print "folderID:", folderID
    Debug.Print "coll is init:", Not cFolders Is Nothing
    Debug.Print "coll count:", cFolders.Count
    Err.Clear
    cFolders folderID
    Debug.Print "key exists:", Err.Number = 0
    Debug.Print "mainURL:", mainURL
    Debug.Print "cID:", cID
    Debug.Print "webPath:", .webPath
    On Error GoTo 0
    Err.Raise 5
End If
On Error GoTo 0

with just:

On Error Resume Next
.mountPoint = BuildPath(mainMount, cFolders(folderID) & "/")
If Err.Number <> 0 Then
    Debug.Print aInfo.datPath
    Err.Raise 5
End If
On Error GoTo 0

and the dat path will be printed to your Immediate Window.

Thanks!

dcircleinc commented 1 year ago
        I will do later and send to you, have to wait until the office is closed.     ---- On Wed, 07 Jun 2023 04:30:04 -0400  ***@***.******@***.***> wrote ----  

Thanks for testing. It seems that the dat file on that particular computer has some other type of convention that I haven't seen before. It would be great if you could send me the dat file for me to have a look at. The dat file only contains the folder and the file names but no information about the account or any other web setting - if you are happy to send it over then just paste it here under a new comment. You can find the path by replacing the previous: On Error Resume Next .mountPoint = BuildPath(mainMount, cFolders(folderID) & "/") If Err.Number <> 0 Then Debug.Print "lineText:", lineText Debug.Print "relPath:", relPath Debug.Print "folderID:", folderID Debug.Print "coll is init:", Not cFolders Is Nothing Debug.Print "coll count:", cFolders.Count Err.Clear cFolders folderID Debug.Print "key exists:", Err.Number = 0 Debug.Print "mainURL:", mainURL Debug.Print "cID:", cID Debug.Print "webPath:", .webPath On Error GoTo 0 Err.Raise 5 End If On Error GoTo 0 with just: On Error Resume Next .mountPoint = BuildPath(mainMount, cFolders(folderID) & "/") If Err.Number <> 0 Then Debug.Print aInfo.datPath Err.Raise 5 End If On Error GoTo 0 and the dat path will be printed to your Immediate Window. Thanks!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

cristianbuse commented 1 year ago

Hi @dcircleinc ,

In case you are not able to send the dat file, then you could drag the dat file into an online hex editor like hexed and then send me some print screens (for at least 2 folders). I am only interested in the signature of the folders. For example on my computer I get a 0x0100... preceded by a 0x02 at 8 bytes offset. The names of the folders should be readable as they are stored in UTF16 on Windows dat files. For example: image

My suspicion is that your particular computer has a different folder/directory signature. Thanks!

guwidoe commented 1 year ago

@dcircleinc , do you also get an error when trying to use this function for getting the local path?

dcircleinc commented 1 year ago

I will try to do this ASAP, I have to go to the location as it is at a workplace and I can't interfere during their daily work. They shut their systems down at night, so I can't remote in anymore. I'm also not sure how to use the immediate window, I do see it, do I need to run the macro from within VBA and then look in the Immediate window or will it display the info as long as the module is loaded?

Ryan Taliercio

---- On Wed, 14 Jun 2023 09:10:46 -0400 Guido Witt-Dörring @.***> wrote ---

https://github.com/dcircleinc , do you also get an error when trying to use https://gist.github.com/guwidoe/038398b6be1b16c458365716a921814d for getting the local path?

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1591181289, or https://github.com/notifications/unsubscribe-auth/AAHBDF7TFKW3AVUK7GNSGBTXLGZ5NANCNFSM6AAAAAAY3M4NDU. You are receiving this because you were mentioned.

guwidoe commented 1 year ago

Hi @dcircleinc ,

I'm not sure what your question about the immediate window is getting at. There are lots of resources online explaining the immediate window such as the official documentation and various third party sources.

dcircleinc commented 1 year ago

Not sure if this is right.

I don't see the name of the folder I'm trying to access in the .dat file. There doesn't seem to be anything special about this OneDrive setup compared to the other systems.

---- On Tue, 13 Jun 2023 04:22:43 -0400 Cristian Buse @.***> wrote ---

Hi https://github.com/dcircleinc ,

In case you are not able to send the dat file, then you could drag the dat file into an online hex editor like https://hexed.it/ and then send me some print screens. I am only interested in the signature of the folders. For example on my computer I get a 0x0100... preceded by a 0x02 at 8 bytes offset. The names of the folders should be readable as they are stored in UTF16 on Windows dat files. For example: https://user-images.githubusercontent.com/23198997/245405677-6af1e7af-f77f-46c2-892d-f868adc6c4bb.png My suspicion is that your particular computer has a different folder/directory signature. Thanks!

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1588793571, or https://github.com/notifications/unsubscribe-auth/AAHBDF3OUGOKBP27AYK6PNDXLAPNFANCNFSM6AAAAAAY3M4NDU. You are receiving this because you were mentioned.

cristianbuse commented 1 year ago

Hi @dcircleinc ,

Are you sure the syncronization is on? I.e. do you have a Personal OneDrive in the taskbar?

image

dcircleinc commented 1 year ago
        Yes on and running, and all synced. The file is opened from within excel which has a link to the onedrive as well, but when changes are made we can see the  sync icon “processing” and then it completes. I haven’t reinstalled OneDrive, would that fix/reset the issue? Ryan Taliercio    ---- On Sat, 17 Jun 2023 15:51:39 -0400  ***@***.******@***.***> wrote ----  

Hi @dcircleinc , Are you sure the syncronization is on? I.e. do you have a Personal OneDrive in the taskbar?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

cristianbuse commented 1 year ago

Thanks @dcircleinc ,

Can you also please try the solution suggested by Guido? If his doesn't work either then we can rule out a bug in my solution.

Also, can you please check how many folders do you in the following path? Maybe send a screenshot. C:\Users\{yourUserName}\AppData\Local\Microsoft\OneDrive\settings There should only be a single Personal folder which is the one my solution (and Guido's) is reading. Within the Personal folder should be the dat file that you were reading with the hex editor. When is the last time the dat file was syncronized (Date Modified)? I am thinking that maybe there is another Personal folder somewhere else which is why the solution doesn't work. For example it's 19/06/2023 09:17 when I am writing this and the screnshot shows that the dat file was updated just 20 minutes ago: image

Many thanks for all the feedback so far!

dcircleinc commented 1 year ago

In the path "C:\Users{yourUserName}\AppData\Local\Microsoft\OneDrive\settings" there is one Personal folder, there is also an additional "Business1" folder (only a single onedrive instance is running that I know of, we don't have a business account here). Within the Personal folder, the .dat was last updated 6/19/2023 1:30AM. There is no other Personal subfolder within this folder. I haven' tried the other suggestion by Guido. 

---- On Mon, 19 Jun 2023 04:20:07 -0400 Cristian Buse @.***> wrote ---

Thanks https://github.com/dcircleinc ,

Can you also please try https://gist.github.com/guwidoe/038398b6be1b16c458365716a921814d suggested by Guido? If his doesn't work either then we can rule out a bug in my solution.

Also, can you please check how many folders do you in the following path? Maybe send a screenshot. C:\Users{yourUserName}\AppData\Local\Microsoft\OneDrive\settings There should only be a single Personal folder which is the one my solution (and Guido's) is reading. Within the Personal folder should be the dat file that you were reading with the hex editor. When is the last time the dat file was syncronized (Date Modified)? I am thinking that maybe there is another Personal folder somewhere else which is why the solution doesn't work. For example it's 19/06/2023 09:17 when I am writing this and the screnshot shows that the dat file was updated just 20 minutes ago: https://user-images.githubusercontent.com/23198997/246769600-9552e8f7-e8f8-4d84-90cc-e27f637b1a92.png Many thanks for all the feedback so far!

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1596730410, or https://github.com/notifications/unsubscribe-auth/AAHBDFYY2UTBALFWOHX2GHTXMADTPANCNFSM6AAAAAAY3M4NDU. You are receiving this because you were mentioned.

cristianbuse commented 1 year ago

Thanks @dcircleinc ,

If you do have a chance to try Guido's solution then please let me know the result.

Otherwise, without seeing the dat file, I'm afraid there isn't much I can do. I totally understand if you are not able to share due to company policy.

dcircleinc commented 1 year ago

I imported Guido's vb instead and tried the same named function, (I put in an on error resume next to avoid error for user),  but also didn't return/find a path so no file was saved. It did however work properly like your code on another test computer. 

I suppose I could send you the .dat directly but would not want it posted online, if that is a possibility.

---- On Mon, 19 Jun 2023 07:55:05 -0400 Cristian Buse @.***> wrote ---

Thanks https://github.com/dcircleinc ,

If you do have a chance to try Guido's solution then please let me know the result.

Otherwise, without seeing the dat file, I'm afraid there isn't much I can do. I totally understand if you are not able to share due to company policy.

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1597048394, or https://github.com/notifications/unsubscribe-auth/AAHBDF6HLVD2BPIK4MDLMKDXMA4ZTANCNFSM6AAAAAAY3M4NDU. You are receiving this because you were mentioned.

cristianbuse commented 1 year ago

Thanks @dcircleinc for confirming!

It would be great if you could send the dat file. Please use my email address at cristian.buse@yahoo.com

cristianbuse commented 1 year ago

Thanks @dcircleinc ,

I just pushed a commit that fixes a wrong assumption. We (me and Guido) have not come across this case before but now thanks to you this should be fixed. Please let me know if this solves the issue.

dcircleinc commented 1 year ago

I pushed the new fix to the system with issue, and the issue is resolved on this system!

Thank you! 

---- On Mon, 19 Jun 2023 10:30:09 -0400 Cristian Buse @.***> wrote ---

Thanks https://github.com/dcircleinc ,

I just pushed a commit that fixes a wrong assumption. We (me and Guido) have not come across this case before but now thanks to you this should be fixed. Please let me know if this solves the issue.

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1597294008, or https://github.com/notifications/unsubscribe-auth/AAHBDF5NPVSW4DDAMAF2XWTXMBO7DANCNFSM6AAAAAAY3M4NDU. You are receiving this because you were mentioned.

cristianbuse commented 1 year ago

Thanks!

cristianbuse commented 1 year ago

Guido also updated his function and it should also work. Thanks again!

dcircleinc commented 8 months ago

We started getting another error one one computer. Onedrive is running.

The error is on this line:

    i = InStr(1, lineText, "_Path", vbTextCompare)

            If i > 0 Then

                relPath = Mid$(lineText, i + 8)

                folderID = Left$(lineText, i - 1)

                If cDirs Is Nothing Then Set cDirs = GetODDirs(aInfo)

                With m_providers.arr(AddProvider())

                    .webPath = mainURL & cID & "/" & relPath & "/"

                    .mountPoint = BuildPath(mainMount, cDirs(folderID) & "/")

                    .baseMount = mainMount

                    .syncID = syncID

                End With

            End If

I just added "on error resume next" above that line and the code executes on this computer, and seems to still find the path. Just not sure what other affect that may have. It has worked on this computer until today.

Ryan Taliercio

---- On Tue, 06 Jun 2023 20:51:52 -0400 Ryan Taliercio @.***> wrote ---

Unfortunately, I got the same error when I changed that line. On the other computers, the code no longer executed like it previously did and didn't find the folder. I reverted back to the original code, and it works on the other computers, but gives the same error on the one in question.  

Ryan Taliercio

---- On Tue, 06 Jun 2023 13:16:14 -0400 Cristian Buse @.***> wrote ---

Thanks https://github.com/dcircleinc ,

I can see what the problem is. The folder count (coll count) cannot possibly be just 1 as surely you have more than 1 folder in your Personal OneDrive. What this means is that the algorithm in the GetODDirs method cannot find the folders as most likely you have a different byte configuration for the dat file. The method reads all the bytes and then searches for folder headers (hex x02 followed by x01000000).

Could you please change https://github.com/cristianbuse/VBA-FileTools/blob/feb2a11a917616b888e275ce385fec0e456c4f5a/src/LibFileTools.bas#L2288:

For stepSize = 16 To 8 Step -8

to:

For stepSize = 8 To 8 Step -8

and try again to see if it works. Thanks!

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1579159594, or https://github.com/notifications/unsubscribe-auth/AAHBDF4RQH2AYFCJZZVQ5HDXJ5QV5ANCNFSM6AAAAAAY3M4NDU. You are receiving this because you were mentioned.

guwidoe commented 8 months ago

Hi @dcircleinc, do you also get an error when trying to use this function?

dcircleinc commented 8 months ago

I don't have that VB imported into the project, I just call the function from LibFileTools directly.

I have a line that calls "GetRemotePath" which is in LibFileTools I believe, but I'm not even sure I need to use it.

It just stopped working on one system today, I have no idea what would have changed. It does work with the on error resume next, so maybe that's OK to just keep it in there.

Ryan Taliercio

---- On Sat, 09 Mar 2024 11:22:14 -0500 Guido Witt-Dörring @.***> wrote ---

Hi https://github.com/dcircleinc, do you also get an error when trying to use https://gist.github.com/guwidoe/038398b6be1b16c458365716a921814d?

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1986903450, or https://github.com/notifications/unsubscribe-auth/AAHBDF7HG5GNMIWUEFSC7CTYXMZLNAVCNFSM6AAAAAAY3M4NDWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBWHEYDGNBVGA. You are receiving this because you were mentioned.

dcircleinc commented 8 months ago
        I will have to wait until after hours to test this alternate code to import . Would I just remove Libfiletools and import this instead and call the function the same way from this alternate version  (so I don’t have to modify any other vb code that calls the function)? One clue that may help is that on this computer yesterday I logged out the user from onedrive app and then signed them in with a different user, but keeping the same original onedrive local folder location. Still “on error resume next” solves that line’s error and it still was able to retrieve the path without further error. I hope this helps?Ryan Taliercio    ---- On Sat, 09 Mar 2024 11:22:14 -0500  ***@***.******@***.***> wrote ----  

Hi @dcircleinc, do you also get an error when trying to use this function?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

guwidoe commented 8 months ago

Exactly, you can drop it in instead of GetLocalPath from LibFileTools to test.

cristianbuse commented 8 months ago

Hi @dcircleinc ,

Thanks for raising this issue. Let's continue the conversation in #21