PRJ: Cannot Execute Macros with Optional Arguments

Last reviewed: November 24, 1997
Article ID: Q124369
The information in this article applies to:
  • Microsoft Project for Windows, version 4.0
  • Microsoft Project for the Macintosh, version 4.0

SYMPTOMS

If a Visual Basic, Applications Edition, sub procedure in Microsoft Project is defined with only optional arguments, it will appear in the list of available macros. If you attempt to run the macro, the following will occur:

  • When you attempt to run the macro by choosing a toolbar button, Microsoft Project displays the following error message:

          Cannot find the macro 'macroname'
    
  • You are unable to run the macro when you choose the Run button in the Macros dialog box.

WORKAROUND

To keep the procedure from appearing in the list of available macros, use the Private keyword when you declare it. For example, the following procedure appears in the macro list:

   Sub OptTest(Optional dummy As Variant)

If you declare the macro as Private, as in the following example, it will not appear in the macro list:

   Private Sub OptTest(Optional dummy As Variant)

STATUS

Microsoft has confirmed this to be a problem in the products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

In general, only sub procedures with no defined arguments appear in the list of available Microsoft Project macros. However, if a sub procedure is defined with only optional arguments, it will be displayed in the list of available macros.


Additional query words: 4.00
Keywords : kbcode kbprg
Version : 4.0
Platform : MACINTOSH WINDOWS
Issue type : kbprb


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: November 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.