转换 MS Access "OLE Objects" 成纯 JPEG 格式最好的方法是使用 Access 的内置功能,使用 VBA (Visual Basic for Applications)脚本。以下是一段示例 VBA 代码:
Sub ConvertOLEsToJPG()
Dim oleobj As OLEObject
Dim jpgImage As IPicture
Dim olePicturePath As String
Dim tempJPEGPath As String
Dim i As Integer
' Loop through all the ole objects in the database
For Each oleobj In CurrentProject.AllForms(0).Controls
If TypeOf oleobj Is OLEObject Then
' Get the path to the OLE object picture
olePicturePath = oleobj.Source
' Convert the OLE object to a JPEG image
olePicturePath = Replace(olePicturePath, ".OLEO",".JPG")
olePicturePath = Replace(olePicturePath, ".HLP","")
Set jpgImage = CreateObject("jpeg.jpg")
jpgImage.Src = olePicturePath
' Save the JPEG image to a temporary file in a hidden subfolder
tempJPEGPath = ThisWorkbook.Path & "\temp\" & "ole_" & i & ".jpg"
jpgImage.PictureType = 1
jpgImage.Export tempJPEGPath
i = i + 1
End If
Next oleobj
' Erase the subfolder if it exists
Kill ThisWorkbook.Path & "\temp\"
' Delete the source OLE object pictures
For i = 1 To ActiveWorkbook.Worksheets.Count
ActiveWorkbook.Worksheets(i).OLEObjects("OLEPicture").Delete
Next i
Debug.Print "OLE Objects converted to JPEG: " & i & " files"
Set jpgImage = Nothing
Set oleobj = Nothing
End Sub
你可以直接运行这个 VBA 脚本来将 Access MDB 中的所有 OLE Objects (Object Linking and Embedding) 转換成纯 JPEG 格式,然后将转换后的 JPEG 文件存储在一个隐藏的子文件夹中。需要注意的是,这个方法不会将 OLEObject 图片转换成 Bitmap 或位图格式。
如果你需要进一步的帮助,我将很乐意提供帮助。
领取专属 10元无门槛券
手把手带您无忧上云