0

When I call this code, and I navigate into sub folders I experience a constant refresh. The refresh resets the focus of the mouse and keyboard onto the object.

Dim testWindows As Object
Dim path As String: path = "absolute-path-to-OneDrive-location"
Set testWindows = CreateObject("Shell.Application").BrowseForFolder(0, "Title", path)

If I am creating a new folder within that window and naming it, after a regular interval the focus is ejected during the refresh and the process of renaming is restarted. This makes it hard to write the entire name of the new folder in one go. If I don't wait for the refresh then while I am typing the folder is selected again and it removes what was recorded to record the next keyboard struck.

If I disconnect the internet the problem remains.
If I disconnect OneDrive (close the app) it does not create this event of refreshing the window. The sequence is regular, something like every 12 seconds.

Community
  • 1
  • 1
Dev1n.101
  • 35
  • 7
  • Your code isn't runnable on my device ... do you have a typo in the above? Should be `Set testWindows = CreateObject("Shell.Application").BrowseForFolder(0, "Title", 0, path)`? – JohnM Jul 03 '23 at 14:29
  • And, adjusting that line, for info: this works fine on my device ... Windows 10, OneDrive personal, when using the path of the OneDrive base folder or a folder within that – JohnM Jul 03 '23 at 14:30
  • Yes the code works, the path I entered here was for information. I am guessing the weird regular refresh when creating a new folder and while naming it, is not something everybody is going to have... which probably is going to be hard to debug. However, I thought maybe somebody has an idea how to proceed since the window is generated by the system and not by a specific form inside the VBA project. – Dev1n.101 Jul 03 '23 at 17:59
  • Do you have "files on demand" set on the local folder? I've noticed that in some cases (eg) looping over the files from VBA can cause all the files to become downloaded locally. You may be seeing something similar to that? – Tim Williams Jul 03 '23 at 18:00
  • Yes you need file on demand to have good synch. perf. using OneDrive. The more I think about it the less I see how I could deal with the problem. – Dev1n.101 Jul 05 '23 at 07:15
  • Seems like right after you create the folder and try to rename it it's a problem, but after that if I right-click and select "Rename" then it seems to be stable until you click off the renamed folder. – Tim Williams Jul 05 '23 at 16:47
  • This approach doesn't seem to suffer from the same problem: https://stackoverflow.com/a/26392703/478884 – Tim Williams Jul 05 '23 at 22:54
  • I will check it, thank's for that possible solution. – Dev1n.101 Jul 06 '23 at 14:37

0 Answers0