Working With Other Workbooks And Files

ft*

ra

If a workbook is open, you can activate it using the Activate method of the Workbook object. When you activate the workbook, it becomes the currently selected workbook in Excel. The Activate method has no parameters. You can use it by specifying the workbook to activate followed by the method, for example:

SelectedWorkbook.Activate.

If, when you activate a particular workbook, you have the workbook open in multiple windows, the activate statement activates the first window that contains the specified workbook. For example, the code Workbooks( "budget.

xls" ).Activate activates the first window which has the window title budget.xls.

When you use Application.Workbooks to return the collection of open workbooks, it returns all workbooks, including those that are hidden, but it does not return any open add-ins. In order to return a specific add-in you need to reference the add-in by name. For example, the code Workbooks ( "OpenAddin.xla" ).Open opens the specified add-in file. Remember, just like workbooks, if you do not specify the path, Excel looks for the workbook in the current folder. To avoid any problems caused by Excel not locating the specified file, use the complete path statement as part of the name. See Chapter 15 for more information on Add-ins.

I Type additional statements to perform if the workbook is open.

—E Type statements to perform if the workbook is not open.

-■ The macro checks to see if the workbook is open. If not, the workbook is opened.
0 0

Post a comment