ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

VBA: How to Open Excel Workbooks

Updated on December 25, 2012

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

Workbooks.open(filepathasstring)

i.e.

Workbooks.open("C:\Users\Jonathan\Test.xlsx")


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.

Workbooks.Open("C:\Users\Jonathan\test.xlsx",ReadOnly)

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

Workbooks.Open(Sheets("Sheets1").Range("A1"))

Comments

    0 of 8192 characters used
    Post Comment

    No comments yet.

    Click to Rate This Article