Thus, I created this code for my task that directly extracts the geotag data from a group of image files' properties in a folder that is specified in the excel file (so it can be applied to different folders). Each file's file name, longitude, latitude, and altitude are supposed to be copied and pasted into a new row in the Excel worksheet. I'm currently experiencing an Error 424: Object Needed. I'm not sure what is wrong with the code or whether I'm simply overlooking anything simple. I've tried other codes I've found on Stack and online as well but they didn't work the way I needed either so I ended up trying to make it myself using those as a reference.
Any help is much appreciated.
Here is the full code I have for this task:
Sub ExtractPhotoData()
'Declare variables
Dim FSO As Object
Dim SourceFolder As Object
Dim FileItem As Object
Dim Image As Object
Dim RowCounter As Integer
'Set up the file system object and source folder
Set FSO = CreateObject("Scripting.FileSystemObject")
Set SourceFolder = Worksheets("Sheet2").Cells(2, 9).Value
'Loop through each file in the source folder
For Each FileItem In SourceFolder.Files
'Check if the file is an image
If InStr(1, FileItem.Type, "image") > 0 Then
'Load the image
Set Image = CreateObject("WIA.ImageFile")
Image.LoadFile FileItem.Path
'Extract the longitude, latitude, and altitude data
Dim Longitude As String
Dim Latitude As String
Dim Altitude As String
Longitude = Image.Properties("GPS Longitude").Value
Latitude = Image.Properties("GPS Latitude").Value
Altitude = Image.Properties("GPS Altitude").Value
'Paste the data into the worksheet
RowCounter = RowCounter + 1
Cells(RowCounter, 1).Value = FileItem.Name
Cells(RowCounter, 2).Value = Longitude
Cells(RowCounter, 3).Value = Latitude
Cells(RowCounter, 4).Value = Altitude
End If
Next FileItem
End Su