Public Sub Media()
    Dim sFileName As String
    Dim lHandle As Long
    Dim lFileSize As Long
    Dim sTemp As String
    Dim lOffset As Long
    Dim sMedia As String
   
    'This code assumes an OLE object called OLE1 exists on your form
    OLE1.CreateEmbed ("C:\SourceFile.jpg")
    OLE1.Refresh
   
    'Save the OLE object to a temp file so we can convert it
    sFileName = "C:\OLETemp.tmp"
    lHandle = FreeFile
   
    Open sFileName For Binary As lHandle
        OLE1.SaveToOle1File (lHandle)
    Close lHandle
   
    'get the size of the file so we can read thru it
    lFileSize = FileLen(sFileName)
   
    'iterate through the temp file to convert it to a string value
    Open sFileName For Binary As lHandle
        lOffset = 1
        Do While lOffset <= lFileSize
            If lFileSize - lOffset >= 5000 Then
                sTemp = String$(5000, " ")
            Else
                sTemp = String$((lFileSize - lOffset) + 1, " ")
            End If
   
            Get lHandle, lOffset, sTemp
            sMedia = sMedia & sTemp
            lOffset = lOffset + 5000
        Loop
    Close lHandle
   
    'Open the constituent record and add the media
    Dim oRec As CRecord
    Set oRec = New CRecord
    oRec.Init oREAPI.SessionContext
   
    oRec.Load 280
   
    Dim oMedia As IBBMedia
    Set oMedia = oRec.Media.Add
   
    oMedia.Fields(MEDIA_fld_Object) = sMedia
    oMedia.Fields(MEDIA_fld_Type) = "Picture"

    oRec.Save
    oRec.CloseDown
    Set oRec = Nothing
End Sub

 
Note: This cannot be done in .NET as the OLE container is not available. Please review the following Microsoft article: Visual Studio 2005 and Visual Studio .NET do not provide an OLE container control for Windows Forms

Disclaimer: We provide programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes you are familiar with Microsoft Visual Basic and the tools used to create and debug procedures. Our Customer Support can help explain the functionality of a particular procedure, but we will not modify, or assist you with modifying, these examples to provide additional functionality. If you are interested in learning more about the VBA and API modules, contact your account manager.