XL: How to Use a Toolbar Button to Open a File Indirectly
ID: Q142585
|
The information in this article applies to:
-
Microsoft Excel for Windows, versions 5.0, 5.0c
-
Microsoft Excel for Windows NT, version 5.0
-
Microsoft Excel for the Macintosh, versions 5.0, 5.0a
-
Microsoft Excel for Windows 95, versions 7.0, 7.0a
-
Microsoft Excel 97 for Windows
SUMMARY
In Microsoft Excel, 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 INFORMATIONMicrosoft Excel 5.0 and 7.0
To associate a workbook with a custom button, do the following:
- In Microsoft Excel, create a new workbook.
- Point to Macro on the Insert menu, and then click Module.
- In the module sheet, type the following code:
Sub Test()
End Sub
- On the Edit menu, point to Sheet, and then click Hide. This hides the
module sheet.
- On the View menu, click Toolbars.
- In the Toolbars dialog box, click Customize. Select "Custom" in the
Categories list box.
- To add the button to an existing toolbar, drag one of the custom
toolbar buttons over the toolbar and release the mouse button. To
create a new toolbar which contains the toolbar button, drag the
custom toolbar button over an area in the workbook and release the
mouse button.
- Select the "Test" macro in the Assign Macro dialog, and click OK.
This will assign the macro Test to the custom button.
- In the Customize dialog box, click Close.
- On the File menu, click Save.
- On the File menu, Click Close.
When you click the custom button, your file is opened. (Note that because
the sample macro has no commands, it runs without performing any
actions).
Microsoft Excel 97 and Microsoft Excel 98
To associate a workbook with a custom button, do the following:
- In Microsoft Excel, create a new workbook.
- Press ALT+F11 to activate the Visual Basic Editor. (Or, click the Tools
menu, point to Macro, and then click Visual Basic Editor.)
- Click Module on the Insert menu. In the Code window, type the
following code:
Sub Test()
End Sub
- Click Close and Return to Microsoft Excel on the File menu to return
to the workbook.
- On the View menu, point to Toolbars and click Customize.
- Click the Command tab in the Toolbars dialog box. Select Macros in
the Categories list box.
- Drag the Custom Button over a toolbar and release the mouse button.
- Right-click the toolbar button and select Assign Macro. Select the
"Test" macro in the Assign Macro dialog, and click OK. This will
assign the macro Test to the custom button.
- In the Customize dialog box, click Close.
- On the File menu, click Save.
- 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.
REFERENCESMicrosoft Excel 97
For more information about customizing toolbars, click the Office
Assistant, type customizing toolbars, click Search, and then click to
view the appropriate topic.
NOTE: If the Assistant is hidden, click the Office Assistant button on
the Standard toolbar. If Microsoft Excel Help is not installed on your
computer, please see the following article in the Microsoft Knowledge
Base:
Q120802 Office: How to Add/Remove a Single Office Program or Component
Microsoft Excel 7.0 for Windows 95
For more information about customizing toolbars, click Answer Wizard on
the Help menu, and type the following on the search line:
How do I create a custom toolbar?
Click Search, and then double-click the "Create a custom toolbar" topic.
Microsoft Excel version 5.0
"Visual Basic User's Guide," version 5.0, Chapter 34, "Customizing Your
Workspace"
Additional query words:
5.0 5.00a 5.00c 8.00 XL97 XL7 XL5
Keywords : kbprg kbdta kbdtacode PgmHowto KbVBA
Version : MACINTOSH:5.0,5.0a; WINDOWS:5.0,5.0c,7.0,7.0a,97; winnt:5.0
Platform : MACINTOSH WINDOWS winnt
Issue type : kbhowto
|