XL98: How to Use a Toolbar Button to Open a File Indirectly (193427)



The information in this article applies to:

  • Microsoft Excel 98 Macintosh Edition

This article was previously published under Q193427

SUMMARY

In Microsoft Excel 98 Macintosh Edition, you can indirectly associate a workbook with a custom button in another workbook by assigning a macro in the associated workbook to the button.

For example, if you have a workbook named "My Workbook" that contains a button, you can indirectly associate a second workbook called "Main Workbook" with that button by assigning a Microsoft Visual Basic for Applications module in "Main Workbook" to the button. When you click the button in "My Workbook," the second workbook, "Main Workbook," is opened automatically.

MORE INFORMATION

To associate a workbook with a custom button, do the following:

  1. In Microsoft Excel, create a new workbook.
  2. Press OPTION+F11 to activate the Visual Basic Editor. (Or, click the Tools menu, point to Macro, and then click Visual Basic Editor.)
  3. Click Module on the Insert menu. In the Code window, type the following code:
           Sub Test()
           End Sub
    						
  4. Click Close and Return to Microsoft Excel on the File menu to return to the workbook.
  5. On the View menu, point to Toolbars and click Customize.
  6. Click the Command tab in the Toolbars dialog box. Select Macros in the Categories list box.
  7. Drag the Custom Button over a toolbar and release the mouse button.
  8. Click Modify Selection in the Customize dialog box, and then click Assign Macro on the menu that appears. Click Test Macro name listbox, and then click OK.

    This will assign the macro Test to the custom button.
  9. In the Customize dialog box, click Close.
  10. On the File menu, click Save.
  11. On the File menu, Click Close.
When you click the custom button, your file is opened; because the sample macro has no commands, it runs without performing any actions.

Modification Type:MajorLast Reviewed:9/11/2002
Keywords:kbhowto KB193427