Show AllShow All

Use DDE

Two programs exchange information by engaging in a DDE conversation on a DDE channel. A program can conduct more than one conversation with Microsoft Query, but each conversation occurs on a different channel.

The program that initiates the conversation is called the destination program; the program that responds to the destination program is called the source program. Microsoft Query is always the source program in a DDE conversation. This means that other programs are always the ones to initiate a DDE conversation with Microsoft Query.

Note  Not all programs support DDE. To find out if your program does, consult your program's documentation.

DDE Channels

There are two types of DDE channels: system channels and query channels.

You use a system channel in a DDE conversation between the destination program and Microsoft Query to get general and query-related information. In addition to providing information about queries, the system channel also lets you retrieve information about the system, such as the current connections, open queries, and the status of the destination program.

You use a query channel in a DDE conversation between the destination program and a specific query (for example, Query1) in Microsoft Query. To use a query channel, the query window must have already been opened using a system channel.

How DDE Works

You can compare a DDE conversation to a typical conversation between two people. For example, in a job interview, the interviewer may ask the applicant a series of interview questions. The interviewer (the destination) initiates and requests information from the applicant (the source) and records the information on a piece of paper (the worksheet or document). Of course, the applicant can also ask questions of the interviewer and establish a two-way conversation.

Similarly, the participating programs in a DDE conversation pass information back and forth. For example, to use DDE to communicate with Microsoft Query, a Visual Basic for Applications procedure might perform these steps:

  1. The procedure opens a channel by using the DDEInitiate method.
  2. Optionally, the procedure sends information, such as what the available data sources or current connections are, to Microsoft Query.
  3. The procedure activates Microsoft Query. This step enables Microsoft Query to accept commands. At this point, either the user or the procedure can build or modify a query. The procedure can send commands directly to Microsoft Query by using the DDEExecute method.
  4. After the user or procedure exits Microsoft Query, control returns to the destination program. The procedure can retrieve query data and send it back to the destination program by using the DDERequest method, or the procedure can send data to Microsoft Query.
  5. The procedure closes the channel by using DDETerminate.

For details about specific DDE methods in Visual Basic for Applications, see Visual Basic Help.