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.

Use the built-in Open dialog box

Use the built-in Open dialog box

- [Instructor] Elsewhere In this course, I show you how to find the full path to a file within the Windows operating system by working in File Explorer. In this movie, I will show you how to do the same thing, but this time allow the user to select the file from within Excel VBA. My sample file is 04_01_OpenDialog, and you can find it in the Chapter 4 folder of the Exercise Files collection. We don't need to use any of the data in the worksheets, so I'll press Alt F11 to move to the Visual Basic Editor. And here I have a code module that has a subroutine called GetFullPath. I start by declaring a variable string F name as a string, and then below that I have a message box that says the "The file's full path is," and then uses the value that we just got. So the question is how do we identify the file? And for that we can use a version of the open dialogue box. And the code to bring that up is string F name, because we're going to assign the file path from the open dialogue box to that…

Contents