XL: Running a Microsoft Project Macro from Microsoft Excel

ID: Q133710

The information in this article applies to:

SUMMARY

This article contains an example to demonstrate how Microsoft Excel can run a Microsoft Project macro using DDE (dynamic data exchange) and Visual Basic for Applications code.

MORE INFORMATION

Microsoft provides programming examples 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. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/support/supportnet/refguide/

This example starts Microsoft Project and then runs a macro from the global macros.

1. In Microsoft Excel, create a new workbook.

2. In Microsoft Excel 97, click the Tools menu, point to Macro, and click

   Visual Basic Editor. Then, click Module on the Insert menu.

   In earlier versions, on the Insert menu, click Macro, and then click
   Module.

3. Type the following information in the module sheet (you may need to
   alter the macro to specify the appropriate locations for the files on
   your computer):

   Sub Run_Project_Macro()

       'Opens Microsoft Project
       Shell("c:\project\winproj.exe")

       'Initiates a DDE channel to Microsoft Project
       Chan = DDEInitiate("WINPROJ", "system")

       'Activates Microsoft Project
       Application.ActivateMicrosoftApp xlMicrosoftProject

       'Runs the Project global macro "AdjustDates"
       Application.DDEExecute Chan, "AdjustDates"

       'Terminates the DDE channel
       Application.DDETerminate Chan

   End Sub

4. To run the macro, on the Tools menu, click Macro. Select the
   appropriate macro name and then click Run.

For additional information about using DDE, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q99845
   TITLE     : Excel: Communication Between Excel and Access Using DDE

Additional query words: 4.00 4.10 5.00 5.00c 7.00 8.00 97 XL97
Keywords          : kbinterop kbprg kbdta kbdtacode KbVBA offinterop xlwin 
Version           : WINDOWS:5.0,5.0c,7.0,97
Platform          : WINDOWS
Issue type        : kbhowto

Last Reviewed: May 17, 1999