The information in this article applies to:
SUMMARYTo automate the querying process between Microsoft Query and another program, you can create a macro that logs into a data source from within Microsoft Query. To do this, the macro must have the correct connection string. You can obtain this connection string from an existing query through a dynamic data exchange (DDE) channel to the query. MORE INFORMATION
To obtain the connection string required by the Microsoft Query, call
ODBCLOGON by initiating a DDE session to a query that is currently
logged into a data source and perform a DDE request of the
connectionstring item:
Visual Basic Code ExampleMicrosoft provides examples of Visual Basic for Applications procedures 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. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft Support professionals can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.
The DDERequest method returns the array "connect" that contains a
valid connection string that can be used by the ODBCLOGON command in
order to connect through a DDE control.
NOTE: If you are using Microsoft Query 97, you must modify the line that initiates the DDE channel. This line must include the correct name for the query. In Microsoft Query 97, the query name is similar to "Query 1 from <Data Source Name>." For example, if the data source that the query uses is named "My DataSource," change the DDEInitiate line to the following:
Microsoft Excel Version 4.0 Macro ExampleMicrosoft provides macro 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 macro is provided as is and Microsoft in no way guaranties that the following code can be used in all situations and will not support modifications of the code to suit specific customer requirements.
The defined name CONNECT will contain a valid connection string that
can be used by the ODBCLOGON command in order to connect through a DDE
control.
NOTE: If you are using Microsoft Query 97, you must modify the line that initiates the DDE channel. This line must include the correct name for the query. In Microsoft Query 97, the query name is similar to "Query 1 from <Data Source Name>." For example, if the data source that the query uses is named "My DataSource," change the DDEInitiate line to the following:
REFERENCES
"Microsoft Query User's Guide," pages 134-144
DDERequest Method Additional query words: 5.00 8.00 97 xl97
Keywords : kbprg kbtool kbusage |
Last Reviewed: November 9, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |