如何使用 VBA 从 Excel 工作表中的形状图片中获取诸如纬度、经度等 EXIF 信息?并且可以在不从工作表或压缩的Excel工作簿中提取或复制图片的情况下获得吗?
我可以使用以下代码遍历压缩文件夹内容。
Public Sub ReadZip()
Dim vZipFileName As Variant
vZipFileName = "C:\Users\erogrou\Desktop\Test.zip"
Dim objShell, objFolder
Set objShell = CreateObject("shell.application")
Set objFolder = objShell.Namespace(vZipFileName)
Dim vFilename As Variant
If (Not objFolder Is Nothing) Then
Debug.Print objFolder.self.Path
For Each vFilename In objFolder.items
Debug.Print vFilename
Next
End If
Set objFolder = Nothing
Set objShell = Nothing
End Sub
Run Code Online (Sandbox Code Playgroud)
对您来说幸运的是,澳大利亚中北部集水区管理局的 Andrew Phillips编写的一段漂亮的代码正是这样做的。
它是作为一个类模块提供的,所以我没有想在这里重新列出它
当前代码可以从 Access 导入到 Excel,在我的情况下,我需要将函数从 32 位更改为 64 位,如下所示:
私有声明函数 VirtualAlloc Lib "kernel32" (ByVal Address As Long, ByVal Size As Long, ByVal AllocationType As Long, ByVal Protect As Long) As Long
对此使用 PntSafe
Private Declare PtrSafe Function VirtualAlloc Lib "kernel32" (ByVal Address As Long, ByVal Size As Long, ByVal AllocationType As Long, ByVal Protect As Long) As Long