Inserts data into a DataObject object using the specified data format.
Syntax
object.SetData [data], [format]
The SetData method syntax has these parts:
Part | Description |
object | Required. An object expression that evaluates to an object in the Applies To list. |
data | Optional A variant containing the data to be passed to the DataObject object. |
format | Optional. A constant or value that specifies the format of the data being passed, as described in Settings. |
Settings
The settings for format are:
Constant | Value | Description |
vbCFText | 1 | Text (.txt files) |
vbCFBitmap | 2 | Bitmap (.bmp files) |
vbCFMetafile | 3 | Metafile (.wmf files) |
vbCFEMetafile | 14 | Enhanced metafile (.emf files) |
vbCFDIB | 8 | Device-independent bitmap (DIB) |
vbCFPalette | 9 | Color palette |
vbCFFiles | 15 | List of files |
vbCFRTF | -16639 | Rich text format (.rtf files) |
Remarks
These constants are listed in the Visual Basic (VB) object library in the Object Browser.
The data argument is optional. This allows you to set several different formats that the source component can support without having to load the data separately for each format. Multiple formats are set by calling SetData several times, each time using a different format. If you wish to start fresh, use the Clear method to clear all data and format information from the DataObject.
The format argument is also optional, but either the data or format argument must be specified. If data is specified, but not format, then Visual Basic will try to determine the format of the data. If it is unsuccessful, then an error is generated. When the target requests the data, and a format was specified, but no data was provided, the source’s OLESetData event occurs, and the source can then provide the requested data type.
It's possible for the GetData and SetData methods to use data formats other than those listed in Settings, including user-defined formats registered with Windows via the RegisterClipboardFormat()
API function. However, there are a few caveats: