Search code examples
ms-accessvba

How to open a folder in Windows Explorer from VBA?


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?


Solution

  • 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.