Update "Tag" attribute of a picture or vidoeo file with VBA RRS feed

  • Question

  • Thank you for taking the time to read my question.

    I have an Access DB that is able to read all files in a folder and subfolders and get the attributes of the files like file name, date picture taken, camera model... and so on.

    I'm wondering if I can update the files with Tag information using VBA. I've done a lot of searching and am getting some mixed results. Some say no, some say use a .dll, but the .dll only does certain attributes... so I'm confused.

    Here is a snippet of my code:

    Dim tnum As Integer
        Dim dbs As DAO.Database
        Dim rst As DAO.Recordset
        Dim i As Long
        Dim objShell As Object
        Dim objFolder As Object
        Dim objFolderItem As Object
        Dim FSO As Object
        Dim oFolder As Object
        Dim Fil As Object
        Dim SubFld As Variant
        Dim colFolders As New Collection
        Dim vFolderName As Variant
        Set dbs = CurrentDb
        Set rst = dbs.OpenRecordset("tblPics")
        Set objShell = CreateObject("Shell.Application")
        Set FSO = CreateObject("scripting.FileSystemObject")
        Set oFolder = FSO.GetFolder(MainFolderName)
        Me.txtDirectory = oFolder
        For Each Fil In oFolder.Files
            Set objFolder = objShell.Namespace(oFolder.Path)
            Set objFolderItem = objFolder.ParseName(Fil.Name)
            If Right(objFolderItem, 3) = "JPG" Or Right(objFolderItem, 3) = "PNG" Or Right(objFolderItem, 3) = "AVI" Or Right(objFolderItem, 3) = "MP4" Then
                Select Case Right(objFolderItem, 3)
                Case "JPG"
                    FileCountJPG = FileCountJPG + 1
                Case "PNG"
                    FileCountPNG = FileCountPNG + 1
                Case "AVI"
                    FileCountJPG = FileCountJPG + 1
                Case "MP*"
                    FileCountMP = FileCountMP + 1
                End Select
                With rst
                    !FileName = objFolder.GetDetailsOf(objFolderItem, 0)
                    !FilePath = objFolder.GetDetailsOf(objFolderItem, 177)
                    !FileSize = objFolder.GetDetailsOf(objFolderItem, 1)
                    !ImgType = objFolder.GetDetailsOf(objFolderItem, 2)
                    !DateTaken = objFolder.GetDetailsOf(objFolderItem, 3)
                    !DateCreated = objFolder.GetDetailsOf(objFolderItem, 4)
                    !CameraModel = objFolder.GetDetailsOf(objFolderItem, 30)
                    !Resolution = objFolder.GetDetailsOf(objFolderItem, 31)
                    !CameraMaker = objFolder.GetDetailsOf(objFolderItem, 32)
                    !ProgramName = objFolder.GetDetailsOf(objFolderItem, 35)
                    !BitDepth = objFolder.GetDetailsOf(objFolderItem, 160)
                    !HorizontalRez = objFolder.GetDetailsOf(objFolderItem, 161)
                    !Width = objFolder.GetDetailsOf(objFolderItem, 162)
                    !Height = objFolder.GetDetailsOf(objFolderItem, 164)
                    !EXIFVersion = objFolder.GetDetailsOf(objFolderItem, 230)
                    !ExposureBias = objFolder.GetDetailsOf(objFolderItem, 232)
                    !ExposureProgram = objFolder.GetDetailsOf(objFolderItem, 233)
                    !ExposureTime = objFolder.GetDetailsOf(objFolderItem, 234)
                    !FStop = objFolder.GetDetailsOf(objFolderItem, 235)
                    !FlashMode = objFolder.GetDetailsOf(objFolderItem, 236)
                    !FocalLength = objFolder.GetDetailsOf(objFolderItem, 237)
                    !ISOSpeed = objFolder.GetDetailsOf(objFolderItem, 239)
                    !LightSource = objFolder.GetDetailsOf(objFolderItem, 242)
                    !MaxAperture = objFolder.GetDetailsOf(objFolderItem, 243)
                    !MeteringMode = objFolder.GetDetailsOf(objFolderItem, 244)
                    !Orientation = objFolder.GetDetailsOf(objFolderItem, 245)
                    !ProgramMode = objFolder.GetDetailsOf(objFolderItem, 247)
                    !WhiteBalance = objFolder.GetDetailsOf(objFolderItem, 250)
                    !SharingStatus = objFolder.GetDetailsOf(objFolderItem, 269)
                End With
            End If

    Is there such a thing as .SetDetaislOf() or something like that?


    Thursday, August 30, 2018 4:39 PM

All replies

  • Is there such a thing as .SetDetaislOf() or something like that?


    Probably not without using a third-party DLL to give you write access to it. If the DLL you're finding is not allowing you to do it, then you'll have to find another one that does give you access to write to the Tag attribute. Otherwise, to do everything through VBA, you'll have to know the complete structure of the file and then modify it using binary/hex methods.

    Just my 2 cents...

    Thursday, August 30, 2018 4:46 PM
  • Yikes... well my VBA and programming in general is entry to moderate so not sure I will be able to figure out anything requiring binary/hex.

    I'll keep searching.

    Thank you for the quick reply. Have a great day!

    Thursday, August 30, 2018 4:49 PM
  • Hi,

    I have heard about DBPIX before. Have you looked into it? It might have the functionality you're looking for.

    Good luck!

    Thursday, August 30, 2018 5:06 PM