Access - Export images from Image controls in forms

前端 未结 4 803
广开言路
广开言路 2021-01-15 05:08

I have been searching for a way to extract images from access forms. A search on Google will nearly always point to OLEtoDisk. This software allows to export images stor

4条回答
  •  执笔经年
    2021-01-15 05:46

    Finally here is the code that worked as intended : Export a PNG image from a form's Image control.

    Public Function savePict(pImage As Access.Image)
        Dim fname As String 'The name of the file to save the picture to
        fname = Environ("Temp") + "\temp.png" ' Destination file path
    
        Dim iFileNum As Double
        iFileNum = FreeFile 'The next free file from the file system
    
        Dim pngImage As String 'Stores the image data as a string
        pngImage = StrConv(pImage.PictureData, vbUnicode) 'Convert the byte array to a string
    
        'Writes the string to the file
        Open fname For Binary Access Write As iFileNum
            Put #iFileNum, , pngImage
        Close #iFileNum
    End Function
    

提交回复
热议问题