Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a folder in Windows Explorer from VBA?

Tags:

vba

ms-access

I want to click a button on my access form that opens a folder in Windows Explorer.

Is there any way to do this in VBA?

like image 983
VBwhatnow Avatar asked Jun 26 '12 10:06

VBwhatnow


People also ask

How do I get Windows Explorer to open to a specific folder?

To open Windows File Explorer to a specific folder, create a shortcut to “%SYSTEMROOT%\explorer.exe /e,<folder>”, where “<folder>” is the folder of your choice.


2 Answers

You can use the following code to open a file location from vba.

Dim Foldername As String Foldername = "\\server\Instructions\"  Shell "C:\WINDOWS\explorer.exe """ & Foldername & "", vbNormalFocus 

You can use this code for both windows shares and local drives.

VbNormalFocus can be swapper for VbMaximizedFocus if you want a maximized view.

like image 155
VBwhatnow Avatar answered Sep 19 '22 11:09

VBwhatnow


The easiest way is

Application.FollowHyperlink [path] 

Which only takes one line!

like image 29
Brian Battles Avatar answered Sep 16 '22 11:09

Brian Battles