![]() The second part is to open the file for which you still need to be dependent on the First Method (VBA Workbooks.open Method). There are 5 arguments in the Application.GetOpenFileName but will only look at the basics like we did it in the first method. Now let us try to understand this method with the help of an example. ![]() The first part does not open the file which you want to open. This Part allows you to browse through your computer and select the path where your file is saved. The first part of this method is Application.GetOpenFileName. This method gives the option to browse in your computer to the location where your file is saved and opens that particular Workbooks which you want to open. Method #2 – Get Open FilenameĪs you know the challenges we face in the First method of the change in path and the File name, this method avoids both of the challenges. This makes the Job tedious and it is not error-free as well. So to make sure your macro runs perfectly without giving you an error, we will use the second method which is easy to handle and will not give you an error even when you don’t remember the pathname or even when the name of the file changes. So if the Path/Name of the file changes you need to change the VBA code of the Macro. The macro will not work even if the Name of the file changes by a single letter. This becomes challenging because many people don’t remember the path and if the Path of the file where it is saved changes a bit, the macro will not work. The path mentioned above is quite simple because there are no folders and subfolders to get the Workbooks. ![]() After running the macro, you will find the excel file is automatically opened. As you can see in the above code, the macro will open the Excel file with the name “Test File.xlsx” which is saved in the D drive of the computer. Step 8: Run the code by pressing the F5 key or by clicking on Play Button.
0 Comments
Leave a Reply. |