Excel: Using Excel's Macro Recorder to Record an SQL QueryLast reviewed: November 4, 1994Article ID: Q80111 |
Summary:
When using the Microsoft Excel Macro Recoder to record a SQL Query in a macro that opens a Query file created in Q+E, the header line "Q+E for <Driver>" must be removed. If the header line is not removed, it will be included in the recorded macro code and cause the macro to fail when executed again. More Information: A query file created and saved in Q+E will always include the line "Q+E for <Driver>" as a header line. When the query file is executed in Q+E or Excel, that line is ignored. However, if the file is used when recording a SQL Query macro, the line is included in the macro code. When recording the macro, the query will execute properly; however, the inclusion of the header line will cause the macro to fail when executed again. If the line is not removed, the macro code will appear as follows:
=DB.SQL.QUERY(2,"Q+E 3.0 for SQLServerUSE pubs;SELECT * FROM SQLserver|dbo.authors;",1,,FALSE)This line will fail when the macro is executed again. With the header line removed, a properly recorded macro line will appear as follows:
=DB.SQL.QUERY(2,"USE pubs;SELECT * FROM SQLserver|dbo.authors;",1,,FALSE)This line will not fail when the macro is executed again. Reference(s): "Q+E for Microsoft Excel User's Guide," version 3.0, pages 33-36, 70-71 "Microsoft Excel User's Guide," for Windows, version 3.0, pages 582-586
|
KBCategory: kbother
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |