Export (0) Print
Expand All

Visual Basic Reference

DataText Property Example

This example sends data to the Microsoft Graph application, so you must have MS Graph installed on your system to run the example. (This is installed by most Microsoft Office components.) Create a form about one-half the size of the screen with a CommandButton control (Command1) in the upper-left corner of the form and an OLE container control (OLE1) placed below the CommandButton.

When you place the OLE container control on the form, the Insert Object dialog box is displayed. Choose Cancel and press F5 to run the example.

Private Sub Command1_Click ()
Dim Msg, NL, TB   ' Declare variables.
   TB = Chr(9)   ' Tab character.
   NL = Chr(10)   ' Newline character.
   ' Create data to replace default Graph data.
   Msg = TB + "Drew" & TB & "Teresa" & TB & "Bob"
   Msg = Msg + NL & "Eric" & TB & "1" & TB & "2" & TB & "3"
   Msg = Msg + NL & "Ted" & TB & "11" & TB & "22" & TB & "33"
   Msg = Msg + NL & "Arthur" & TB & "21" & TB & "32" & TB & "23"
   ' Send the data using the DataText property.
   ' Activate MSGRAPH as hidden.
Ole1.DoVerb - 3
   If Ole1.AppIsRunning Then
      Ole1.DataText = Msg
      ' Update the object.
      Ole1.Update   
   Else
      MsgBox "Graph isn't active."
   End If
End Sub
Sub Form_Load ()
   Ole1.Format = "CF_TEXT"   ' Set the file format to text.
   Ole1.SizeMode = 2   ' Autosize.
   Ole1.CreateEmbed "", "MSGRAPH"
End Sub
Show:
© 2014 Microsoft