I'm getting Run-time error '76': Path not found in VBA. This used to work for me and the only thing that I changed recently was adding my folders to Onedrive (which I feel it could be the cause).
ChDir (Environ("USERPROFILE") & "\Desktop")
When I use the Immediate window I can print the path without issue there, however I'm getting my company domain as shown below. I don't understand why is not processed by the macro. Could someone help guide me the way out of this?
print(Environ("USERPROFILE") & "\Desktop")
C:\Users\myname.DOMAIN\Desktop
I cannot duplicate the problem on my machine, but you can try this workaround which strips out anything after the [first] period...
Dim sProfile As String
Dim vSplit As Variant
sProfile = Environ("USERPROFILE")
vSplit = Split(sProfile, ".")
sProfile = vSplit(0)
MsgBox sProfile & "\Desktop"