Open Multiple Workbook in One Go Using Application.GetOpenFileName(MultiSelect:=True)

 Example-1

Multiselect:=True, let you select multiple files in one go and store the location of all files in a variable and let you open one file or workbook at one time.

Note: It is important to note that the type of variable holding file or files name should be Variant.

Sub OpenFile()

On Error Resume Next

Dim str As Variant

Dim i As Integer

str = Application.GetOpenFilename(MultiSelect:=True)

Debug.Print str

For i = LBound(str) To UBound(str)

Debug.Print str(i)

'Workbooks.Open str(i)

'Debug.Print ActiveWorkbook.Name

'ActiveWorkbook.Close

Next

End Sub


Comments

Popular posts from this blog

Power Automate - Automatically fetch data from Power BI in to Excel and Send the copy of the Excel file via Email

Function to Paste Excel Range on Outlook Mail Body (In text not image) Function Name - rngHTML()

Separate Text (Characters) & Numbers from Alpha Numeric String Using Formula and Macro (VBA)