DataText Property

See Also08COSU              Example2XC55CB>Low

Applies To

OLE control2HQDVVU.


Sends or retrieves a string from the specified OLE object.  Not available at design time.


[form.]ole.DataText [ = data ]


To send a string to an object, first set the Format property to a format the object supports.  Use the ObjectGetFormats and ObjectAcceptFormats properties to get a list of formats supported by an object.

When getting data from an object, the DataText property returns the string sent from the object, ending at the first null character.

The DataText string must be less than 64K.

OLE Automation provides an easier and more reliable solution for sending data and commands to and from an object.  If an object supports OLE Automation, you can access the object through the Object1MHI551 property, or using the CreateObject0M4P7F and GetObjectTLKUVF functions.

Data Type


See Also

CreateObject Function0M4P7F

Data Property2W08UX1

Format Property23FQAYP

GetObject FunctionTLKUVF

Object Property1MHI551

ObjectAcceptFormats PropertyOSMY8L

ObjectAcceptFormatsCount PropertyCGOYZQ

ObjectGetFormats Property1CNFCPK

ObjectGetFormatsCount PropertyDDT1TX

DataText Property Example

The example sends data to the Microsoft Graph application, so you must have Graph to run the example. Create a form about half the size of the screen with a command button (command1) in the upper left corner of the form and an OLE control (OLE1) placed below the command button.

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

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 through the DataText property.
   ' Activate MSGRAPH as hidden.
   Ole1.Verb = -3
   Ole1.Action = 7
   If Ole1.AppIsRunning Then
      Ole1.DataText = Msg
      ' Update the object.
      Ole1.Action = 6
      MsgBox "MSGRAPH is not active."
   End If
End Sub

Sub Form_Load ()
   Ole1.Format = "CF_TEXT"         ' Set the format to text.
   Ole1.SizeMode = 2               ' Autosize.
   Ole1.Class = "MSGRAPH"          ' Embed an MSGRAPH object.
   Ole1.Action = 0
End Sub