Gets or sets an image to the value of a Data Element in the Data Segment.
Syntax:
Parameters:
Remarks:
When assigning an image file to the data element value, the object must be of type IPictureDisp and the binary content of the file overwrites any existing value. When attempting to retrieve an image from a data element value, an image object IPictureDisp is returned only if the data element value is of the following image binary:
- Bitmap
- Icon
- Metafile
If the data element value is not an image file, the property returns an empty object or NULL. However, please note that this does not mean that data is not present. If the property returns an empty value, use the DataLength property of the data element to indicate if data is present and then use either Value or FileValue to retrieve the data.
The vElement and vSubElement parameters are variants whereby the identifier or the position can be passed. If an identifier is specified then it is passed as a string parameter; otherwise the position can be passed as a numeric parameter.
For example, the following statements are identical. The statements below gets an image from a simple element "785" which is at position 5 of a data segment.
- Set oFile = oDataSegment.DataElementFileValue(5)
- Set oFile = oDataSegment.DataElementFileValue("785")
Example 1: Getting the image
Dim oDataSegment As Fredi.ediDataSegment
Dim oImage As IPictureDisp
....
' Get first data segment in document.
Set oDataSegment = oEdiDoc.FirstDataSegment
' Get the data segment containing image value.
Set oDataSegment = oDataSegment.GetDataSegmentByPos("\ISA\GS\ST\PWK\EFI\BIN")
' Set the picture object from the value of the data element in the segment.
Set Form1.Picture1.Picture = oDataSegment.DataElementImageValue("785")
Example 2: Setting the image
Dim oDataSegment As Fredi.ediDataSegment
....
' Get first data segment in document.
Set oDataSegment = oEdiDoc.FirstDataSegment
' Get the data segment to store the image.
Set oDataSegment = oDataSegment.GetDataSegmentByPos("\ISA\GS\ST\PWK\EFI\BIN")
' Set the value of the data element to the image
Set oDataSegment.DataElementImageValue("785") = Form1.Picture2.Picture
' Save document with assigned image to new file.
oEdiDoc.Save App.Path & "\TestOutput.Txt"
MsgBox "Image saved to file " & App.Path & "\TestOutput.Txt"
Sample