Solved Folder not open

sergio vieira

Member
Local time
Today, 11:48
Joined
Apr 22, 2024
Messages
35
Good Morning. I have a pc asus On this PC I have a folder called "Backups", located in "My Documents". In an Access form I have the following command: Dim abre
abre = Shell("explorer.exe C:\Users\Documents\Backups", vbNormalFocus). However, I discovered that it only opens the folder if I use it like this: Dim abre
abre = Shell("explorer.exe C:\Users\asus\Documents\Backups", . My problem: What if I install the application on another computer that is not "asus", which variable should I use? I appreciate any help in advance. Thank you
 
The environment variable UserProfile will give you the beginning of the path including the username.

Code:
Dim UserProfilePath as String
UserProfilePath = Environ("Userprofile")
Dim abre
abre = Shell("explorer.exe "  & UserProfilePath & "\Documents\Backups", vbNormalFocus)
 
The environment variable UserProfile will give you the beginning of the path including the username.

Code:
Dim UserProfilePath as String
UserProfilePath = Environ("Userprofile")
Dim abre
abre = Shell("explorer.exe "  & UserProfilePath & "\Documents\Backups", vbNormalFocus)
Thank you Sonic8. Now is ok.
 

Users who are viewing this thread

Back
Top Bottom