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
From the course: Excel VBA: Managing Files and Data
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Determine if a workbook exists4m 41s
-
(Locked)
Determine if a folder (directory) exists4m 22s
-
(Locked)
Detect whether a file is open4m 40s
-
(Locked)
Open a workbook3m 23s
-
(Locked)
Close a workbook5m 34s
-
(Locked)
Save a workbook under a new name4m 15s
-
(Locked)
Save a workbook as a CSV file5m 19s
-
-
-
-
-
-
-
-