Excel VBA Open a Folder Excel VBA Open a Folder vba vba

Excel VBA Open a Folder


If you want to open a windows file explorer, you should call explorer.exe

Call Shell("explorer.exe" & " " & "P:\Engineering", vbNormalFocus)

Equivalent syxntax

Shell "explorer.exe" & " " & "P:\Engineering", vbNormalFocus


I use this to open a workbook and then copy that workbook's data to the template.

Private Sub CommandButton24_Click()Set Template = ActiveWorkbook With Application.FileDialog(msoFileDialogOpen)    .InitialFileName = "I:\Group - Finance" ' Yu can select any folder you want    .Filters.Clear    .Title = "Your Title"    If Not .Show Then        MsgBox "No file selected.": Exit Sub    End If    Workbooks.OpenText .SelectedItems(1)

'The below is to copy the file into a new sheet in the workbook and paste those values in sheet 1

    Set myfile = ActiveWorkbook    ActiveWorkbook.Sheets(1).Copy after:=ThisWorkbook.Sheets(1)    myfile.Close    Template.Activate    ActiveSheet.Cells.Select    Selection.Copy    Sheets("Sheet1").Select    Cells.Select    ActiveSheet.PasteEnd With