- Computers & Software»
- Computer Science & Programming»
- Programming Languages
VBA: How to Open Excel Workbooks
Opening a Workbook in Excel
The easiest method for opening a workbook in Excel is to use the keyboard shortcut Control+O. One of the main advantages of keyboard shortcuts is that they work regardless of what version of excel you are using.
After pressing Control+O, a dialogue box will open prompting you to navigate to the file path where your Excel workbook is saved.
If you are using Excel 2010, perhaps the easiest alternative to using the keyboard shortcut, is adding an open button to the quick access toolbar.
Click here to configure the Quick Access Toolbar
Opening a Workbook from Visual Basic
Use the code below to open a workbook in visual basic
Opening A Workbook Read-Only from VBA
Opening a workbook read-only allows you to view its contents, but doesn't allow you to save changes.
If you are working with files you don't wan't changed it is good idea to open read-only.
Opening a Workbook from Filename in Cell
If you will later need to change the path file you will be opening you can place the file path in a cell.
Assuming the file name is in Range A1 use the following code
Ready to Proceed?
In the Next module we will learn to combine text and string variables for use in a filepath. Click here when you are ready to proceed.