vba to select a folder from a sharepoint

drop05

Active Member
Joined
Mar 23, 2021
Messages
285
Office Version
  1. 365
Platform
  1. Windows
Hi i have the below VBA, and i am trying to double click the cell and have it pop up to select a folder but it is only bringing up folders on my machine and not from a sharepoint site, any assistance on editing the code to allow share point select would be appreciated

VBA Code:
If Not Application.Intersect(target, Range("config_FolderBrowse")) Is Nothing Then
        cancel = True

    Dim diaFolder As Office.FileDialog
    Dim Msg As String
    Dim Style As Variant
    Dim Title As String
    Dim Response As Variant
   
   
    'Open the file dialog
    On Error GoTo ErrorHandler
    Set diaFolder = Application.FileDialog(msoFileDialogFolderPicker)
    diaFolder.AllowMultiSelect = False
    diaFolder.Title = "Select a folder then hit OK"
    diaFolder.Show
    ActiveCell.Offset(rowOffset:=0, columnOffset:=1).Value = diaFolder.SelectedItems(1)
    Set diaFolder = Nothing
    Exit Sub
   
ErrorHandler:
    Msg = "No folder selected, you must select a folder for program to run"
    Style = vbError
    Title = "Need to Select Folder"
    Response = MsgBox(Msg, Style, Title)
   
   
End If
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
You need to use the UNC path of the sp server as the InitialFileName property of the dialog.
Note: it is not the URL (https:/something). It is \\ServerNameHere\topFolderHere\etc.
 
Upvote 0
Forgot to mention that you may need to map to it in order to discover the path (using Windows File Explorer). Or ask IT person.
You can eliminate repetitive referencing like so
VBA Code:
With diaFolder
    .AllowMultiSelect = False
    .Title = "Select a folder then hit OK"
    .InitialFileName = " \\ServerNameHere\topFolderHere\etc."
    .Show
End With
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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