cristianbuse / VBA-FileTools

Useful methods for interacting with the file system
MIT License
81 stars 23 forks source link

Runtime Error 9: Dim mainMount As String: mainMount = libParts(3) #19

Closed henrykx closed 9 months ago

henrykx commented 9 months ago

I am using GetLocalPath(ThisWorkbook.FullName). Works great on one computer (Win10) Runtime Error on another computer (Win11). Interestingly, the runtime error occurs in some VBA Projects (on the Win11 machine), not in others (on the same Win11 machine).

So far, I don't have a clue in which cases the error occurs. But with some guidance, maybe we can find out.

Thank you Henryk.

henrykx commented 9 months ago

Even more interesting: In a particular VBA Project, it worked yesterday. But gives me the runtime error today.

henrykx commented 9 months ago

I am trying to identify different behaviours of the two systems. It seems like the main difference is in Code Line 2496: If parts(3) = "ODB" Then

In case where parts(3) = "ODB" the error occurs. In case where parts(3) = "DOKS" the error does not occur.

Not sure yet, what to make out of that. Still open for support!

henrykx commented 9 months ago

I give up. If anyone is interested, I can try to tell details. For my case, I switch to another solution.

cristianbuse commented 9 months ago

Hi @henrykx ,

Thank you for the feedback!

It must be the "DOKS" that is causing the issue. I only ever accounted for "ODB". I was not working today hence my late reply. I will try to look into this either tomorrow or Monday.

cristianbuse commented 9 months ago

Hi @henrykx ,

Are you using the latest version of this repository?

Does this solution work for you?

cristianbuse commented 9 months ago

Hi @henrykx ,

I cannot replicate the issue. How did you end up having "DOKS" in your code? Did you manually change the code yourself or are you using another solution? Thanks!

hstoeckert commented 9 months ago

Hi @cristianbuse,

I have no idea, how/why the code picked "DOKS" instead of "ODB". I did not change the code. Used it as provided.

BUT: The "DOKS" instance is the one that worked. I got the issue with the "ODB". I did not change the code. Used it as provided.

The differences in lines of code before "DOKS/ODB" which I collected were:

I have now switched to solution #32 from this list: https://stackoverflow.com/questions/33734706/excels-fullname-property-with-onedrive So that's all I could provide.

cristianbuse commented 9 months ago

Hi @hstoeckert ,

I am a bit confused. Solution #32 is this exact repository.

Also, if the INI file is missing (hasIniFile = FALSE), it is possible that the OneDrive account is disconnected on the machine that does not work

hstoeckert commented 9 months ago

Yes, of course @cristianbuse! Sorry. #33 of course :-)

hstoeckert commented 9 months ago

Hi @hstoeckert ,

I am a bit confused. Solution #32 is this exact repository.

Also, if the INI file is missing (hasIniFile = FALSE), it is possible that the OneDrive account is disconnected on the machine that does not work

I don't think the machine was disconnected. Although I am not sure what you mean by disconnected. OneDrive was installed. The computer was online (as I accessed via remote desktop). The file were synced (as I worked on my local machine in parallel, teted and also saw the OneDrive icons).

Also, if it was disconneced (offline), this should still be working, as there still is a local path, where all the files are located, right? If that's not the case, I would have to rethink quite a lot of stuff now! :-)

cristianbuse commented 9 months ago

@hstoeckert

I don't think the machine was disconnected. Although I am not sure what you mean by disconnected. OneDrive was installed. The computer was online (as I accessed via remote desktop). The file were synced (as I worked on my local machine in parallel, teted and also saw the OneDrive icons).

I meant the account is disconnected, as in Unlink this PC was used under OneDrive Settings -> Account

Also, if it was disconneced (offline), this should still be working, as there still is a local path, where all the files are located, right? If that's not the case, I would have to rethink quite a lot of stuff now! :-)

If a OneDrive account gets disconnected, then the OD software automatically deletes the information relevant to that account and so the solution in this repository won't be able to read the relevant data (nor other solutions). It makes sense that you should not rely on any solution because while disconnected, none of the local changes are reflected online and viceversa. This is not very likely to happen often. Anyway, please note the rebuildCache parameter in both GetLocalPath and GetRemotePath that allows you to read all the information again if you want to be 100% sure the account is still connected.

Sorry. #33 of course :-)

So, #33 works for you on all machines but #32 does not? That is super weird because Guido (author of #33) and I worked together on this and both our solutions should work exactly the same.

hstoeckert commented 9 months ago

Obviously they don't. Sorry to say! :-) Still, thank you for your efforts.

cristianbuse commented 9 months ago

@hstoeckert ,

There must be something I am missing here. Are you able to share the main INI file from the computer that does not work?

It should be under C:\Users\\AppData\Local\Microsoft\OneDrive\settings\Business1\ and looking like 4b38ba67-4198-4cb5-8121-e1e3dc7dcbb6.ini

If there is any sensitive information in there, like username, then please replace with something generic.

This would help me to replicate the error. Thanks!

cristianbuse commented 9 months ago

Hi @hstoeckert ,

Should I still wait for a response? Thanks!

hstoeckert commented 9 months ago

Hi @cristianbuse,

Currently, I don't have access to the respective client's environment. If it's okay and still interesting for you, I will get back to this thread, once I am again accessing the environment.

cristianbuse commented 8 months ago

Hi @hstoeckert ,

This is now fixed. Thank you for you feedback!