View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Maurizio Borrelli[_2_] Maurizio Borrelli[_2_] is offline
external usenet poster
 
Posts: 12
Default GPS Data from JPEG's

Il giorno luned́ 27 aprile 2015 04:16:46 UTC+2, ha scritto:
I have a large number of JPEG files taken from various phones that have GPS latitude and longitude data. I can view this data by looking up the file properties (details) individually in windows explorer.
Is it possible to retrieve this GPS data in VBA? I would like to retrieve the latitude and longitude for each file into a spreadsheet.
I'm using Windows 7 and Excel 365.
I did see some old posts that seemed to relate but the links to solutions were no longer valid.


Hi neilw...,
try:

Public Sub GetExtendedProperty_Test()
Const cstrPath As String = "D:\Path"
Const cstrFilename As String = "Filename.JPG"
Dim p As String

' System.Photo.CameraModel
p = GetExtendedProperty(cstrPath, _
cstrFilename, _
"{14B81DA1-0135-4D31-96D9-6CBFC9671A99}", _
272)
Debug.Print p

' System.GPS.Latitude
p = GetExtendedProperty(cstrPath, _
cstrFilename, _
"{8727CFFF-4868-4EC6-AD5B-81B98521D1AB}", _
100)
Debug.Print p

' System.GPS.Longitude
p = GetExtendedProperty(cstrPath, _
cstrFilename, _
"{C4C4DBB2-B593-466B-BBDA-D03D27D5E43A}", _
100)
Debug.Print p
End Sub

' Windows Properties
' https://msdn.microsoft.com/en-us/lib...77(VS.85).aspx
'
Public Function GetExtendedProperty(ByVal Path As String, _
ByVal Filename As String, _
ByVal formatID As String, _
ByVal propID As String)
Dim sh As Shell32.Shell
Dim fld2 As Shell32.Folder2
Dim fi As Shell32.FolderItem
Dim sfi As Shell32.ShellFolderItem

Set sh = CreateObject("Shell.Application")
Set fld2 = sh.Namespace(Path)
Set fi = fld2.ParseName(Filename)
Set sfi = fi
GetExtendedProperty = sfi.ExtendedProperty(formatID & CStr(propID))

Set sfi = Nothing
Set fi = Nothing
Set fld2 = Nothing
Set sh = Nothing
End Function

--
Ciao! :)
Maurizio