Obtaining Data from Other Applications

Once you initiate a conversation with another application, you can use the DDERequest function to obtain data from the application:

DDERequest(channel, item)

For example, if you initiate a link with the System topic, you can get the list of all topics currently supported by an application, such as Microsoft Excel:

ExcelTopics = DDERequest (ChannelNum, "Topics")

If the specified channel number doesn't refer to an active DDE conversation, DDERequest generates an error. You also get an error if the specified item isn't recognized by the other application. Remember that the set of valid items can vary from topic to topic for the same application.

Obtaining data in this way is similar to using the DDE function in a form in Microsoft Access (in the ControlSource property). However, unlike the DDE function, which requests new data automatically, Microsoft Access code doesn't obtain fresh information until it re-executes the DDERequest function. Because you aren't notified when data in the DDE server changes, you must explicitly request new data when you want it.

Supplying Data to Other Applications

Although the client in a DDE conversation usually obtains data from the server, the client can provide data to the server as well, using the DDEPoke statement:

DDEPoke channum, item, data

For example, if you have initiated a conversation with Microsoft Excel using a worksheet as a topic, you can place a new value—for example, 100—in the upper-left cell of the worksheet:

DDEPoke ChannelNum, "R1C1", "100"

Notice that the data must always be a String or Variant data type. It's up to the other application to interpret the data correctly. In the previous example, for instance, Microsoft Excel interprets "100" as the numeric value 100.