Access - Export images from Image controls in forms

前端 未结 4 848
广开言路
广开言路 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:42

    The picture data is an EMF file, with a wrapper of 8 bytes. This is your routine modified to use the correct file extension

    Public Function savePict(pImage As Access.Image)
        Dim fname As String 'The name of the file to save the picture to
        Dim iFileNum As Double
        Dim bArray() As Byte, cArray() As Byte
        Dim lngRet As Long
    
        fname = Environ("Temp") + "\temp.emf" ' Destination file path
        iFileNum = FreeFile 'The next free file from the file system
    
        ' Resize to hold entire PictureData prop
        ReDim bArray(LenB(pImage.PictureData) - 1)
        ' Resize to hold the EMF wrapped in the PictureData prop
        ReDim cArray(LenB(pImage.PictureData) - (1 + 8))
        ' Copy to our array
        bArray = pImage.PictureData
        For lngRet = 8 To UBound(cArray) 
            cArray(lngRet - 8) = bArray(lngRet)
        Next
    
        Open fname For Binary Access Write As iFileNum
        'Write the byte array to the file
        Put #iFileNum, , cArray
        Close #iFileNum
    End Function
    

提交回复
热议问题