LinkRequest Method Example

This example uses LinkRequest to update the contents of a text box with the values in a Microsoft Excel worksheet. To try this example, you must have Microsoft Excel running on your computer. Place some data in the first cells in the first column in the default worksheet (Sheet1.xls). Paste the code into the Declarations section of a form that has a TextBox control called Text1, and then press F5 and click the form.

Private Sub Form_Click ()
   If Text1.LinkMode = vbNone Then   ' Test link mode.
      Text1.LinkTopic = "Excel|Sheet1"   ' Set link topic.
      Text1.LinkItem = "R1C1"   ' Set link item.
      Text1.LinkMode = vbLinkManual   ' Set link mode.
      Text1.LinkRequest   ' Update text box.
   Else
      If Text1.LinkItem  = "R1C1" Then
         Text1.LinkItem = "R2C1"
         Text1.LinkRequest   ' Update text box.
      Else
         Text1.LinkItem = "R1C1"
         Text1.LinkRequest   ' Update text box.
      End If
   End If
End Sub