如何使用VBA从Excel工作表中的图片中获取EXIF信息 [英] How to obtain EXIF info from picture in an excel worksheet using VBA
问题描述
如何使用VBA从Excel工作表中的形状图片中获取EXIF信息(例如纬度,经度等)?并且可以在不从工作表或压缩的Excel工作簿中提取或复制图片的情况下获得它吗?
How do I obtain the EXIF info like Latitude, Longitude, etc... from a shape picture in an excel worksheet using VBA? And can it be obtained without extracting or copying the picture out of the worksheet or out of the zipped Excel workbook?
我可以使用以下代码遍历压缩的文件夹内容.
I am able to iterate through the zipped folder contents with the following code.
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
推荐答案
Fortunately for you there is a beautiful piece of coding by Andrew Phillips from Australia's North Central Catchment Management Authority that does exactly this.
它作为类模块提供,所以我没有在这里重新列出它
It is provided as a class module so I haven't looked to re-list this here
当前代码可以从Access导入到Excel,在我的情况下,我需要将功能从32位更改为64位:
The current code can be imported from Access to Excel, in my case I needed to change the functions from 32 to 64 bit as so:
私有声明函数VirtualAlloc Lib"kernel32"(ByVal地址长,ByVal大小长,ByVal AllocationType长,ByVal保护长)
Private Declare Function VirtualAlloc Lib "kernel32" (ByVal Address As Long, ByVal Size As Long, ByVal AllocationType As Long, ByVal Protect As Long) As Long
为此使用PntSafe
私有声明PtrSafe函数VirtualAlloc Lib"kernel32"(ByVal地址长,ByVal大小长,ByVal AllocationType长,ByVal保护长)
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
这篇关于如何使用VBA从Excel工作表中的图片中获取EXIF信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!