modify tags (metadata) in jpg files though vba (1 Viewer)

olek_w1

Registered User.
Local time
Today, 04:41
Joined
Jun 4, 2014
Messages
17
Hello,

I've question reqarding modyfying tags (metadata ) in jpg files.

I've found some code which allow to read tags from jpg files through vba
but only read - editing is not possible.

So my question is: Does someone have a vba code which allow modify tags in jpg files? If yes, please provide some code.

( below code for reading tags, requires to turn on following reference in vba editor:
Microsoft Shell controls and Automation )

Code:
Public Function getFileMetadata(fileFolder As String, fileNm As String, _
metadataType As String) As String

    Dim objShell As Shell32.Shell
    Dim objFolder As Shell32.Folder
    Dim objFolderItem As Shell32.FolderItem

    Set objShell = New Shell
    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
      
       Dim i As Integer
       
       For i = 1 To 80
      
         MsgBox "Attribute number: " & i & " value is: " &   objFolder.GetDetailsOf(objFolderItem, i)
       
       Next i
             
       cTxt = cTxt & vbCrLf & "Atributes: " & _
              objFolder.GetDetailsOf(objFolderItem, 6)
           


              
       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
 
Last edited:

BlueIshDan

☠
Local time
Yesterday, 23:41
Joined
May 15, 2014
Messages
1,122
Maybe you might be able to look up code to generate your own jpg files and with that you can replicate the old ones with the new metadata and delete them in the end.
 

olek_w1

Registered User.
Local time
Today, 04:41
Joined
Jun 4, 2014
Messages
17
Dear BlueIshDan,

Your suggestions were very helpfull - I worked around a problem by using batch file...

It was All i needed to solve my problem :)

Thak You very much for Your great help....
 

Users who are viewing this thread

Top Bottom