-
read / display file properties / title
Hello!
I have a code that searches through a folder for filenames that match inputted criteria and generates hyperlinks to those files on my spreadsheet. I want to do the same with the file titles, which are under the file properties? Anyone know how I can read a file's title?
I'm using Excel 2007 and VBA... 2003?
Thanks!
-
ignore that 2003, I'm not sure which version I'm using. Whatever comes with a purchase of Office 2007.
-
Hi jbr0005,
Welcome to the board!
I found this at MS's web site
[VBA]
Dim arrHeaders(35)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\Scripts")
For i = 0 to 34
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Next
For Each strFileName in objFolder.Items
For i = 0 to 34
Wscript.Echo i & vbtab & arrHeaders(i) _
& ": " & objFolder.GetDetailsOf(strFileName, i)
Next
Next
[/VBA]
This is the link
http://technet.microsoft.com/en-us/l.../ee176615.aspx
If you need more help just let us know!
-
I used the prescribed code, but my 'arrHeaders' variable is blank.. I'm not sure if it's responding to the Shell function, because when typing in the '.' they scroll down box that usually pops up, doesn't. Here's what it looks like:
Dim arrHeaders
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FullPath & "CMT-Shell 1-U34-ND-09-2055.pdf")
arrHeaders = objFolder.GetDetailsOf(objFolder.Items, 0)
MsgBox (arrHeaders)
With a blank message box.
-
This one is not blank. First notice that I did not send the file to the folder object I used a folder (FullPath). The first loop is picking up the available options for the folder. (I have no idea if it changes from folder to folder) Then when I am cycling through the files in that directory I check to see if it is the file I am looking for and if it is I display a message box with the information stored in the file's information.
[vba]
Sub kk(iFileName As String)
Dim arrHeaders(35)
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(FullPath) 'just the directory
For i = 0 To 34
arrHeaders(i) = objFolder.GetDetailsOf(objFolder.Items, i)
Next
For Each strFileName In objFolder.Items
If strFileName = iFileName Then
For i = 0 To 34
MsgBox i & vbTab & arrHeaders(i) _
& ": " & objFolder.GetDetailsOf(strFileName, i)
Next
End If
Next
End Sub
[/vba]
EDIT: I Goofed so I fixed it Tommy
-
Thank you so much for the help!!
-
Any quick pointers on how I could get the file name, not the file title, using this same sequence?
-
[VBA]For Each strFileName In objFolder.Items
If strFileName = iFileName Then
For i = 0 To 34 '0 will be the file name all 35 addressable properties are listed.
MsgBox i & vbTab & arrHeaders(i) _
& ": " & objFolder.GetDetailsOf(strFileName, i)
Next
End If
Next
[/VBA]
-
Of course... I tried all numbers but zero Thank you Tommy you've been a great help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules