XL: Syntax Error with Recorded ExecuteExcel4Macro Method

Last reviewed: February 3, 1998
Article ID: Q110310
The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0c
  • Microsoft Excel for the Macintosh, versions 5.0, 5.0a
  • Microsoft Excel for Windows 95, versions 7.0, 7.0a

SYMPTOMS

When you record a Microsoft Visual Basic Programming System, Applications Edition macro command, and the ExecuteExcel4Macro method is recorded, you may receive a syntax error when you run the macro.

CAUSE

A few commands in Microsoft Excel must be recorded using the ExecuteExcel4Macro method because there is no equivalent command in Visual Basic. If the recorded command uses the ExecuteExcel4Macro method, the command may be placed onto two or more physical lines using the line continuation character (_).

For example, the following command is recorded when you change the update option for a link to Manual by clicking Links on the Edit menu:

   ExecuteExcel4Macro "SET.UPDATE.STATUS( _
           ""Word.Document.6|Document2!!DDE_LINK1"",2,2)"

This command will cause a syntax error when you run the macro because the ExecuteExcel4Macro argument is split across lines. Because the ExecuteExcel4Macro argument is a string, it must be contained all on one line.

WORKAROUND

When you use the ExecuteExcel4Macro command, type the command all on one line. If you record a macro, and a line continuation character is incorrectly inserted in the ExecuteExcel4Macro command, delete any line continuation characters in the command so that the command is all on one line.

STATUS

Microsoft has confirmed this to be a problem in the versions of Microsoft Excel listed at the beginning of this article. This problem was corrected in Microsoft Excel 97 for Windows and Microsoft Excel 98 Macintosh Edition.

NOTE: In all versions of Microsoft Excel, commands that follow the ExecuteExcel4Macro command must always be on a single line.

REFERENCES

For more information about the ExecuteExcel4Macro Method, choose the Search button in Help and type:

    Excel 4.0: macro sheets


Additional query words: 5.00 5.00a 5.00c 7.00 7.00a XL7 XL5
Keywords : kbprg PgmOthr
Version : WINDOWS:5.0,7.0; MACINTOSH:5.0
Platform : MACINTOSH WINDOWS
Issue type : kbbug
Solution Type : kbworkaround


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