Visual Basic Reference
For a destination control returns or sets the source application and the topic (the fundamental data grouping used in that application). Use LinkTopic with the LinkItem property to specify the complete data link.
For a source form returns or sets the topic that the source form responds to in a DDE conversation.
The LinkTopic property syntax has these parts:
|object||An object expression that evaluates to an object in the Applies To list.|
|value||A string expression specifying a DDE syntax element.|
The LinkTopic property consists of a string that supplies part of the information necessary to set up either a destination link or source link. The string you use depends on whether you're working with a destination control or a source form. Each string corresponds to one or more elements of standard DDE syntax, which include application, topic, and item.
*Note* While the standard definition for a DDE link includes the application, topic, and item elements, the actual syntax used within applications for a destination link to a source application may vary slightly. For example, within Microsoft Excel, you use the syntax:
Within Microsoft Word for Windows, you use:
application topic item
(Don't use the pipe character [|] or exclamation mark [!].)
Within a Visual Basic application, you use:
The exclamation mark for topic is implicit.
Destination Control To set LinkTopic for a destination control, use a string with the syntax application|topic as follows:
application is the name of the application from which data is requested, usually the executable filename without an extension for example, Excel (for Microsoft Excel).
The pipe character (|, or character code 124) separates the application from the topic.
topic is the fundamental data grouping used in the source application for example, a worksheet in Microsoft Excel.
In addition, for a destination control only, you must set the related LinkItem property to specify the item element for the link. A cell reference, such as R1C1, corresponds to an item in a Microsoft Excel worksheet.
Source Form To set LinkTopic for a source form, set value to an appropriate identifier for the form. A destination application uses this string as the topic argument when establishing a DDE link with the form. Although this string is all you need to set LinkTopic within Visual Basic for a source form, the destination application also needs to specify:
The application element that the destination application uses, which is either the Visual Basic project filename without the .vbp extension (if you're running your application in the Visual Basic development environment) or the Visual Basic application filename without the .exe extension (if you're running your application as a stand-alone executable file). The EXEName property of the App object provides this string in your Visual Basic code unless the filename was changed by the user. (EXEName always returns the actual filename of the application on disk; DDE always uses the original name that was specified in the Project Properties dialog box.)
The item element that the destination application uses, which corresponds to the Name property setting for the Label, PictureBox, or TextBox control on the source form.
The following syntax is an example of a valid reference from Microsoft Excel to a Visual Basic application acting as a source:
You could enter this reference for a destination cell in the Microsoft Excel formula bar.
To activate the data link set with LinkTopic, set the LinkMode property to the appropriate nonzero value to specify the type of link you want. As a general rule, set LinkMode after you set LinkTopic. For a destination control, changing LinkTopic breaks an existing link and terminates the DDE conversation. For a source form, changing LinkTopic breaks all destination links that are using that topic. For these reasons, always set the LinkMode property to 0 before changing LinkTopic. After changing LinkTopic for a destination control, you must set LinkMode to 1 (Automatic), 2 (Manual), or 3 (Notify) to establish a conversation with the new topic.
*Note* Setting a permanent data link at design time with the Paste Link command on the Edit menu also sets the LinkMode, LinkTopic, and LinkItem properties. This creates a link that is saved with the form. Each time the form is loaded, Visual Basic attempts to reestablish the conversation.