ID: Q149998
In Microsoft Excel versions 5.0 and 7.0, you are able to call a Microsoft Excel version 5.0 or 7.0 Visual Basic for Applications procedure from a Microsoft Excel version 4.0 macro.
Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft Support professionals can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.
To call a Visual Basic for Applications macro from a Microsoft Excel version 4.0 macro, do the following:
1. Insert both a Module and a 4.0 Macro sheet in a Microsoft Excel version
5.0 or 7.0 workbook.
2. Place the following code on the Module sheet:
Sub Test()
Msgbox "This is a test"
End Sub
3. Save the workbook as VBA_XLM.xls.
4. On the 4.0 Macro sheet, place the following code:
A1: Test1
A2: =RUN(VBA_XLM.xls!test())
A3: =RETURN()
5. On the 4.0 Macro sheet, place your cursor in cell A1, and do the
following:
a. On the Insert menu, point to Name, and then click Define.
b. In the Define Name dialog box, click Test1 in the Names In Workbook
list.
c. Under Macro, click Command.
The Category list defaults to User Defined.
d. Click Add, and then click OK.
6. Save the workbook.
7. On the Tools menu, click Macro.
8. In the Macro dialog box, click Test1, and then click Run.
You should receive a dialog box with the message "This is a test."
"Microsoft Excel Function Reference," version 4.0, pages 367-368 "Microsoft Excel User's Guide 2," version 4.0, pages 231-255 "Microsoft Excel Visual Basic User's Guide," version 5.0, chapters 1-4
Additional query words: 4.00 5.00 5.0 5.0c 5.00c 7.00
Keywords :
Version : 5.x 7.00
Platform : WINDOWS
Last Reviewed: May 19, 1999