VBA Open Workbook is to open an existing workbook. Workbook represents an object. It is part of workbooks collection. Open is method in an Excel VBA. We use this method to open workbook file when it exists in the folder. Once we know the file or workbook path exists in the folder, we open Workbook using open method. It returns the opened workbook.
Here is the following syntax to open Workbook.
Workbooks.Open(Filename As Sring, [UpdateLinks], [ReadOnly], [Format], [Password], [WriteResPassword], [IgnoreReadOnlyRecommended], [Origin], [Delimiter], [Editable], [Notify], [Converter], [AddToMru], [Local], [CorrtptLoad]) As Workbook
Where FileName is a required parameter. It represents the file name of the Workbook. Remaining parameters are optional arguments.
Let us see the following example. It will open Workbook from the specified location.
'VBA Open Workbook in Excel Sub VBA_Open_Workbook() 'Variable declaration Dim sFileName As String 'File Name to Open sFileName = "D:\VBAF1\Open_Workbook_File.xlsm" 'Open Workbook Workbooks.Open (sFileName) End Sub
If Workbook is not available or doesn’t exists in the specified location, it throws an error. Here is the screen shot of run time error.
You can refer the following link for the step by step instructions.
Click on the following links of the useful resources. These helps to learn and gain more knowledge.