From the course: Excel VBA: Managing Files and Data

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Open a workbook

Open a workbook

- [Instructor] In the previous movie, I showed you how to determine whether a particular Excel file is open or not. In this movie, I will show you how to open files that are currently closed. I'll use two sample files, but the first one is 02_04_OpenWorkbook, and you can find that in the Chapter two folder of the exercise files collection. We're not going to need to use the data or chart in this workbook, so I'll press Alt+F11 to move to the Visual Basic Editor, and here, I have a code module with a subroutine called OpenAWorkbook, and from here, I can type in a single line of code that will open the workbook we want to use. The method we'll call is from the Workbooks collection, so that'll be Workbooks.Open, I'm sure that's not a surprise, then a space, and the file name. I prefer to declare arguments where I have the name of the argument and then a colon and an equals sign and then the value, rather than work inside of parentheses and rely on order. So the argument we'll use is…

Contents