I'm new on here so apologise in advance for any inadvertent breaches of etiquette.
I've been developing an Access database to store details of my photo collection, almost all *JPGs, and using the Windows Image Acquisition API to read/write EXIF data from/to the image files. The documentation at Windows Image Acquisition (WIA) - Win32 apps | Microsoft Docs is fairly limited, but I managed to get everything working OK until it came to dealing with GPS latitude and longitude co-ordinates. I can read them fine, but when I try to write them to an image file I get an error message as follows:
"Run-time error '-2147467259 (80004005)': Unspecified error"
That is is not really very helpful, I think you'll agree.
The essence of the code I'm trying to get to work is:
Where GPSData is a user defined type containing, inter alia, a GPS latitude in degrees/minutes/seconds in a 3 element array of double precision floating point numbers.
The code fails on Set objImg = .Apply(objImg). I'm thinking that the problem is something to do with getting data into the VectorOfUnsignedRationalsImagePropertyType, since there isn't such an animal as an unsigned rational in VBA, but the documentation on how to use vectors of that type is extremely thin, and I have now tried everything I can think of to get things to work and have now run out of ideas. Does anyone have any suggestions?
I've been developing an Access database to store details of my photo collection, almost all *JPGs, and using the Windows Image Acquisition API to read/write EXIF data from/to the image files. The documentation at Windows Image Acquisition (WIA) - Win32 apps | Microsoft Docs is fairly limited, but I managed to get everything working OK until it came to dealing with GPS latitude and longitude co-ordinates. I can read them fine, but when I try to write them to an image file I get an error message as follows:
"Run-time error '-2147467259 (80004005)': Unspecified error"
That is is not really very helpful, I think you'll agree.
The essence of the code I'm trying to get to work is:
Code:
Set objImg = New WIA.ImageFile
Set objIP = New WIA.ImageProcess
Set objVectorLat = New WIA.Vector
With objIP
.Filters.Add (.FilterInfos("Exif").FilterID)
.Filters(1).Properties("ID") = IMG_GPSLAT '= 2
.Filters(1).Properties("Type") = VectorOfUnsignedRationalsImagePropertyType '= 1106
With objVectorLat
.Add GPSData.GPSLat(0), 0
.Add GPSData.GPSLat(1), 0
.Add GPSData.GPSLat(2), 0
End With
.Filters(1).Properties("Value") = objVectorLat
objImg.LoadFile strImgPathCurrent 'Load file for filter application
Set objImg = .Apply(objImg) 'apply filter
objImg.SaveFile strImgPathNew 'save updated image to new/temporary file
End With
Where GPSData is a user defined type containing, inter alia, a GPS latitude in degrees/minutes/seconds in a 3 element array of double precision floating point numbers.
The code fails on Set objImg = .Apply(objImg). I'm thinking that the problem is something to do with getting data into the VectorOfUnsignedRationalsImagePropertyType, since there isn't such an animal as an unsigned rational in VBA, but the documentation on how to use vectors of that type is extremely thin, and I have now tried everything I can think of to get things to work and have now run out of ideas. Does anyone have any suggestions?
Last edited: