See Also Example
Applies To
OLE control.
Description
Sends or retrieves a string from the specified OLE object. Not available at design time.
Usage
[form.]ole.DataText [ = data ]
Remarks
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 Object property, or using the CreateObject and GetObject functions.
Data Type
String
CreateObject Function
Data Property
Format Property
GetObject Function
Object Property
ObjectAcceptFormats Property
ObjectAcceptFormatsCount Property
ObjectGetFormats Property
ObjectGetFormatsCount Property
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
Else
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