Automatically Starting Microsoft Excel Macros Through OLE

Last reviewed: April 29, 1996
Article ID: Q98701
The information in this article applies to:
  • Microsoft FoxPro for Windows, versions 2.5 and 2.5a

SUMMARY

Microsoft FoxPro for Windows can load and run a Microsoft Excel 4.0 macro from a general field. The information below provides the steps for using the Auto_Activate Microsoft Excel macro.

NOTE: These steps do not work with Excel versions greater than 4.0.

MORE INFORMATION

The Auto_Activate macro executes when a Microsoft Excel macro sheet is activated.

To create this macro, do the following:

  1. Create a database in FoxPro with a general field.

  2. Open the general field in FoxPro, and choose Insert Object from the Edit menu.

  3. From the Insert Object list, choose Microsoft Excel Macrosheet. (Microsoft Excel must be a registered server application in order for this option to be available.)

  4. In cell A1, type the following:

    =ALERT("This is the Auto_Activate")

  5. In cell A2, type the following:

    =RETURN()

  6. Select cell A1.

  7. From the Formula menu, choose Define Name. In the Name box, type "Auto_Activate" (without the quotation marks).

  8. In the Macro section of the Define Name dialog box, select Command.

  9. In the Refers To box, type "=$A$1" (without the quotation marks).

  10. In the Category box, make sure User Defined is selected.

  11. Choose Add and then choose OK.

  12. From the File menu, choose Exit, and choose Yes to update the macro sheet.

When selected, this general field will now start Microsoft Excel and run the Auto_Activate macro.


Additional reference words: FoxWin 2.50 2.50a Excel OLE DDE macrosheet
KBCategory: kbinterop kbole kbprg
KBSubcategory: FxinteropDde


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 29, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.