LinkPoke Method

See Also1NECEBO              Example1JWTWML>Low

Transfers the contents of a control to the source application in a dynamic data exchangeDEFDDE (DDE) conversation.

Syntax

control.LinkPoke

Remarks

The control is the name of a text box, picture box, or label involved in a DDE conversation as a destination.  If control is a text box, LinkPoke transfers the current contents of the Text property to the source.  If control is a picture box, LinkPoke transfers the current contents of the Picture property to the source.  If control is a label, LinkPoke transfers the current contents of the Caption property.

Typically, information in a DDE conversation flows from source to destination.  However, LinkPoke allows a destination control to supply data to the source.  Not all source applications will accept information supplied in this way; if the source application does not accept the data, an error occurs.


See Also

LinkExecute Method0JJE0GF

LinkRequest Method3HB029

LinkSend MethodH24SKI


LinkPoke Method Example

The example establishes a DDE link with Microsoft Excel, places some values into cells in the first row of a new worksheet, and charts the values.  LinkPoke sends the values to be charted to the Microsoft Excel worksheet.  To try this example, Microsoft Excel must be installed and in your path.  Paste the code into the Declarations section of a form that has a text box with the default name Text1.  Then press F5 and click the form.

Sub Form_Click ()

   Const NONE = 0, LINK_MANUAL = 2       ' Declare constants.

   Dim Cmd, I, Q, Row, Z                 ' Declare variables.

   Q = Chr(34)                           ' Define quote marks.

   ' Create a string containing Excel macro commands:

   Cmd = "[ACTIVATE(" & Q &"SHEET1" & Q & ")]"

   Cmd = Cmd & "[SELECT(" & Q & "R1C1:R5C2" & Q & ")]"

   Cmd = Cmd & "[NEW(2,1)][ARRANGE.ALL()]"

   If Text1.LinkMode = NONE Then

      Z = Shell("Excel", 4)              ' Start Excel.

      Text1.LinkTopic = "Excel|Sheet1"   ' Set link topic.

      Text1.LinkItem = "R1C1"            ' Set link item.

      Text1.LinkMode = LINK_MANUAL       ' Set link mode.

   End If

   For I = 1 To 5

      Row = I                            ' Define row number.

      Text1.LinkItem = "R" & Row & "C1"  ' Set link item.

      Text1.Text = Chr(64 + I)           ' Put value in Text.

      Text1.LinkPoke                     ' Poke value to cell.

      Text1.LinkItem = "R" & Row & "C2"  ' Set link item.

      Text1.Text = Row                   ' Put value in Text.

      Text1.LinkPoke                     ' Poke value to cell.

   Next I

   Text1.LinkExecute Cmd                 ' Execute Excel commands.

End Sub