Open Workbook Folder Location in File Explorer, not SharePoint

Marhier

Board Regular
Joined
Feb 21, 2017
Messages
128
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
Hi everyone.
I have a section of VBA code where I want it to open the folder where the workbook is saved.

Issue:
We don't have networked drives - they're essentially cloud drives on SharePoint, but we can browse them locally like they are networked.
When my code runs, it opens up the folder structure, at the correct location, but in a Browser via SharePoint.
I want it to open in File Explorer instead

My code is as follows:
VBA Code:
Sub Example()
Dim filePath As String
Dim folderPath As String
filePath = ThisWorkbook.FullName
folderPath = Application.ActiveWorkbook.Path
Call Shell("explorer.exe """ & folderPath & """", vbNormalFocus)
End Sub

If it helps, it seems the general file path it uses when browsing locally, as an example, is as follows:
C:\Users\joe.bloggs\Company Name\Company Name - Current Projects

Is there a way to solve this issue?

All support is greatly appreciated.
Thank you.
Regards,
Marhier.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try this macro, however I suspect the result will be the same as your macro because it also uses the Windows Shell to open the folder.

VBA Code:
Public Sub Open_Folder()
    Dim sh As Object
    Dim folderPath As Variant 'must be a Variant   
    folderPath = ActiveWorkbook.Path
    Set sh = CreateObject("Shell.Application")
    sh.Open folderPath
    'Or
    'sh.Explore folderPath
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,096
Latest member
Anshu121

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top