From the course: Excel VBA: Managing Files and Data

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Determine if a workbook exists

Determine if a workbook exists - Microsoft Excel Tutorial

From the course: Excel VBA: Managing Files and Data

Start my 1-month free trial

Determine if a workbook exists

- [Instructor] Much of the Excel VBA code that you write will operate on the workbook that is currently open. However, more advanced routines will need to open, close and otherwise operate on workbooks elsewhere on your system or somewhere over a network. In this movie, I will show you how to determine whether a particular workbook even exists. My sample file is 0201, does it exist? And that is an Excel macro enabled workbook that you can find in the chapter two folder of your exercise files collection. I won't be working with the body of the workbook instead we'll just go with VBA code. So I'll press alt F11 to move to the visual basic editor. And here you see that I have a code module already open. I have a function at the top that will check for a file and then a subroutine that calls the function and it displays a result. I'll start by adding the only line of code that we need in the function. And that is what we'll…

Contents