DW Faisalabad New Version

DW Faisalabad New Version
Please Jump to New Version

Monday, 10 July 2017

Close and Open

The Close and Open Method in Excel VBA can be used to close and open workbooks. Remember, the Workbooks collection contains all the Workbook objects that are currently open.

Place a command button on your worksheet and add the following code lines:





Note: you can only open sales.xls without specifying the file's path if it's stored in your default file location. The default file location is the folder you see when you open or save a file.

6. You can also use the GetOpenFilename method of the Application object to display the standard open Dialog box and select the file (without actually opening the file).



Result:



7. Next, you can open the workbook as usual.

.