XL: Syntax Error with Recorded ExecuteExcel4Macro Method

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.00a 5.00c 7.00a XL7 XL5

Keywords : kbprg PgmOthr
Version : MACINTOSH:5.0,5.0a; WINDOWS:5.0,5.0c,7.0,7.0a
Platform : MACINTOSH WINDOWS
Issue type : kbbug


Last Reviewed: October 25, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.