I have searched and search with no luck. I have a Access 2010 table that has links to all my pictures (jpgs) and I want to read in the IPTC metadata and display it on the form.
I found the following code but get errors with the SHELL32 section.
I call the program this way and this is the code I am using.
Any help and direction would be helpful shinning some light on it.
Thank you
Jim
Button: Call getFileMetadata("C:\pictures", "mypicture.jpg", "photo")
Option Compare Database
Public Function getFileMetadata(fileFolder As String, fileNm As String, metadataType As String) As String
Dim objShell As New SHELL32.Shell
Dim objFolder As New SHELL32.Folder
Dim objFolderItem As New SHELL32.FolderItem
Set objShell = New Shell
Set objShell = CreateObject("Shell.application")
Set objFolder = objShell.Namespace(fileFolder)
Set objFolderItem = objFolder.ParseName(fileNm)
'I WAS USING THIS FOR .JPG FILES
If metadataType = "photo" Then
Dim cTxt As String
cTxt = "Dimensions: " & objFolder.GetDetailsOf(objFolderItem, 26)
cTxt = cTxt & vbCrLf & "Date Picture Taken: " & _
objFolder.GetDetailsOf(objFolderItem, 25)
cTxt = cTxt & vbCrLf & "Camera Model: " & _
objFolder.GetDetailsOf(objFolderItem, 24)
cTxt = cTxt & vbCrLf & "Type: " & _
objFolder.GetDetailsOf(objFolderItem, 2)
cTxt = cTxt & vbCrLf & "Size: " & _
objFolder.GetDetailsOf(objFolderItem, 1)
getFileMetadata = cTxt
ElseIf metadataType = "DatePicTaken" Then
getFileMetadata = objFolder.GetDetailsOf(objFolderItem, 25)
Else
getFileMetadata = objFolder.GetDetailsOf(objFolderItem, 1)
End If
Set objFolderItem = Nothing
Set objFolder = Nothing
Set objShell = Nothing
'Properties and index:
'================
'0 Name
'1 Size
'2 Type
'3 Date Modified
'4 Date Created
'5 Date Accessed
'6 Attributes
'7 Status
'8 Owner
'9 Author
'10 Title
'11 Subject
'12 Category
'13 Pages
'14 Comments
'15 Copyright
'16 Artist
'17 Album Title
'18 YEAR
'19 Track Number
'20 Genre
'21 Duration
'22 Bit Rate
'23 Protected
'24 Camera Model
'25 Date Picture Taken
'26 Dimensions
'27
'28
'29 Episode Name
'30 Program Description
'31
'32 Audio sample size
'33 Audio sample rate
'34 Channels
'35 Company
'36 Description
'37 File Version
'38 Product Name
'39 Product Version
'40 Keywords
End Function
I found the following code but get errors with the SHELL32 section.
I call the program this way and this is the code I am using.
Any help and direction would be helpful shinning some light on it.
Thank you
Jim
Button: Call getFileMetadata("C:\pictures", "mypicture.jpg", "photo")
Option Compare Database
Public Function getFileMetadata(fileFolder As String, fileNm As String, metadataType As String) As String
Dim objShell As New SHELL32.Shell
Dim objFolder As New SHELL32.Folder
Dim objFolderItem As New SHELL32.FolderItem
Set objShell = New Shell
Set objShell = CreateObject("Shell.application")
Set objFolder = objShell.Namespace(fileFolder)
Set objFolderItem = objFolder.ParseName(fileNm)
'I WAS USING THIS FOR .JPG FILES
If metadataType = "photo" Then
Dim cTxt As String
cTxt = "Dimensions: " & objFolder.GetDetailsOf(objFolderItem, 26)
cTxt = cTxt & vbCrLf & "Date Picture Taken: " & _
objFolder.GetDetailsOf(objFolderItem, 25)
cTxt = cTxt & vbCrLf & "Camera Model: " & _
objFolder.GetDetailsOf(objFolderItem, 24)
cTxt = cTxt & vbCrLf & "Type: " & _
objFolder.GetDetailsOf(objFolderItem, 2)
cTxt = cTxt & vbCrLf & "Size: " & _
objFolder.GetDetailsOf(objFolderItem, 1)
getFileMetadata = cTxt
ElseIf metadataType = "DatePicTaken" Then
getFileMetadata = objFolder.GetDetailsOf(objFolderItem, 25)
Else
getFileMetadata = objFolder.GetDetailsOf(objFolderItem, 1)
End If
Set objFolderItem = Nothing
Set objFolder = Nothing
Set objShell = Nothing
'Properties and index:
'================
'0 Name
'1 Size
'2 Type
'3 Date Modified
'4 Date Created
'5 Date Accessed
'6 Attributes
'7 Status
'8 Owner
'9 Author
'10 Title
'11 Subject
'12 Category
'13 Pages
'14 Comments
'15 Copyright
'16 Artist
'17 Album Title
'18 YEAR
'19 Track Number
'20 Genre
'21 Duration
'22 Bit Rate
'23 Protected
'24 Camera Model
'25 Date Picture Taken
'26 Dimensions
'27
'28
'29 Episode Name
'30 Program Description
'31
'32 Audio sample size
'33 Audio sample rate
'34 Channels
'35 Company
'36 Description
'37 File Version
'38 Product Name
'39 Product Version
'40 Keywords
End Function