So you merely would like to navigate to a given folder! Well, as usual, there are numerous ways to accomplish this.
Method 1 – FollowHyperlink Method
The first method is to use the FollowHyperlink Method. This is a great technique because it requires minimal coding and will open the folder in the user’s default software of choice. The code would look something like:
Application.FollowHyperlink "C:\Program Files\Microsoft Games"
Method 2 – Shell Function
You can use the Shell Function to specify which program to use and pass it whatever variable that application accepts. So for our needs, we can merely use Windows explorer to open the folder we are interested in. The code would look something like:
Dim sPath as String
sPath = "C:\Program Files\Microsoft Games"
Shell "C:\WINDOWS\explorer.exe """ & sPath & "", vbNormalFocus
In the case of the FollowHyperlink Method, you obviously have to ensure that your users’ actually have the program you are trying to utilize to open the folder and be careful with the exe location since it may change depending on OS versions, but you can easily build a more robust function to handle all these exceptions/cases.
Thank you! I learned something new today and will definitely use in the future!
Thank you very much…is amazing.. I like it
help me please ı not open the user profil from yandex.
Dim sPath As String
sPath = “C:\Users\mehmet\AppData\Local\Yandex\YandexBrowser\Application”
Shell “C:\Users\mehmet\AppData\Local\Yandex\YandexBrowser\Application\browser.exe “”” & –profile – directory = “Profile 1 & “””, vbNormalFocus
End Sub
I’m afraid I’m not familiar with Yandex or its syntax. You’d have to find documentations on the subject and follow their instructions.