Working With Other Workbooks And Files

Ex ra

Instead of saving an individual workbook, you can save the entire workspace. You can use workspaces, which have a .xlw extension, if you have multiple workbooks that you need to open simultaneously. If you save them as a workspace, you simply need to open that workspace and all workbooks in the workspace.

To save a workspace, you use the SaveWorkspace method from the Application object. The Filename parameter, the required and only parameter, which you must specify for this method, contains the filename and location where Excel stores, the workspace file. For example, if you type Application. SaveWorkspace "NewWorkspace" Excel saves the current workspace, which includes all open files, with the specified name.

Instead of saving the workbooks into a workspace, you can save each open workbook, using the Save method of the Application object and combining it with a looping statement. The example code cycles through all currently open workbooks and saves them one by one. If you have not previously saved a workbook, Excel prompts you via the Save As dialog box for a file name and location.

Example:

For Each wb in Application.Workbooks wb.Save

Next

—0 Type ThisWorkbook.SaveAs Filename:=UserFile to save the current workbook with the specified filename and path.

Note: See the section "Save a Workbook" for more information on using the SaveAs method.

■ The Save As dialog box requests the information for saving the workbook.

—0 Type ThisWorkbook.SaveAs Filename:=UserFile to save the current workbook with the specified filename and path.

Note: See the section "Save a Workbook" for more information on using the SaveAs method.

■ The Save As dialog box requests the information for saving the workbook.

0 0

Post a comment