How do I edit Extended File Properties in VBA?

Shortmeister1

Board Regular
Joined
Feb 19, 2008
Messages
207
Office Version
  1. 365
  2. 2016
  3. 2013
  4. 2010
  5. 2007
  6. 2003 or older
Platform
  1. Windows
Hi all

I wrote the code below, which quite happily informs me of a selection of file attributes. What I'm struggling with is how to change this from GetDetailsOf to something that would allow me to edit said attributes. Anyone able to give me a pointer please.

Thanks
Martin

VBA Code:
Sub test4()
    Dim sFile As Variant
    Dim objShell
    Dim objDir
    Set objShell = CreateObject("Shell.Application")
    Set objDir = objShell.Namespace("C:\Music\Bible In A Year")
    
    For Each sFile In objDir.Items
        If sFile.Name = "9781473640474_06_0115_BIOY.mp3" Then
            Debug.Print objDir.GetDetailsOf(sFile, 14) 'Album Name
            Debug.Print objDir.GetDetailsOf(sFile, 15) 'Year
            Debug.Print objDir.GetDetailsOf(sFile, 21) 'Title
            Debug.Print objDir.GetDetailsOf(sFile, 26) 'Index
            Debug.Print objDir.GetDetailsOf(sFile, 237) 'Album Artist
        End If
    Next
   
    Set objDir = Nothing
    Set objShell = Nothing
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I have good news and bad news.

The good news is that it can be done. The bad news is that it's not an easy thing to do. But the second lot of good news is that Jaafar posted code recently that does exactly this - it allows you to read and edit a file's extended properties: Reading and Editing Metadata File Properties.

If you're looking to edit the properties of an MP3 file, there is a working example available here: Editing MP3 Tags
 
Upvote 0
Thanks Dan

I'll give this a try tomorrow. If this doesn't work, I'll give up and use python. 😉
 
Upvote 0
You're welcome.
Python won't be any different in terms of what it's doing behind the scenes - it's just the degree to which the hard work has been abstracted away and done for you. Here, Jaafar has done all the hard thinking, but you have to make sure that you add the code to your workbook, is all.
What is it exactly that you're trying to do? Because if it's edit the MP3 metadata, you don't necessarily need to go as far as Extended Properties in order to do that.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,736
Members
452,940
Latest member
Lawrenceiow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top