Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get file summary "title" 1

Status
Not open for further replies.

Doteco

Programmer
Jan 9, 2005
16
AU
When you hover the mouse over a file a "tool tip" listing:-

Type:
Title: - (but only if a title has been given to the file.)
Date Modified: &
Size:

... is displayed. Is there any way in VB6 to get the "Title" component of this information - as opposed to the "name" of the file.

I've tried FSO but that doesn't do it - well, not as far as I can tell.

Thanks, Doug.
 
No, the fso does not do it - but add a reference to the Microsoft Shell Controls and Automation library as well, and Bob's your uncle ...

e.g.
Code:
[blue]Option Explicit

Private Enum ColumnDetail
    detailInfoTip = -1
    detailName = 0
    detailSize = 1
    detailType = 2
    detailModified = 3
    detailAttributes = 4
    detailComment = 5
    detailCreated = 6
    detailAccessed = 7
    detailOwner = 8
    detailUnknown = 9 ' I don't know what this column is for
    detailAuthor = 10
    detailTitle = 11
    detailSubject = 12
    detailCategory = 13
    detailPages = 14
    detailCopyright = 15
    detailCompanyName = 16
    detailModuleDescription = 17
    detailModuleVersion = 18
    detailProductName = 19
    detailProductVersion = 20
    detailSenderName = 21
    detailRecipientName = 22
    detailRecipientNumber = 23
    detailCsid = 24
    detailTsid = 25
    detailTransmissionTime = 26
    detailCallerID = 27
    detailRouting = 28
    detailAudioFormat = 29
    detailAudioSampleRate = 30
    detailAudioSampleSize = 31
    detailChannels = 32
    detailPlayLength = 33
    detailFrameCount = 34
    detailFrameRate = 35
    detailVideoSampleSize = 36
    detailVideoCompression = 37
End Enum

Private Function GetColumnDetail(ByVal strFilename As String, Optional iColumn As ColumnDetail = detailInfoTip)
    Dim fso As FileSystemObject
    Dim myShell As Shell
    Dim myFolder As Folder
    Dim myItem As FolderItem
    Dim lp As Long
    
    Set fso = New FileSystemObject
    Set myShell = New Shell

    Set myFolder = myShell.NameSpace(fso.GetParentFolderName(strFilename))
    Set myItem = myFolder.Items.Item(fso.GetFileName(strFilename))

    GetColumnDetail = myFolder.GetDetailsOf(myItem, iColumn)

End Function

Private Sub Command1_Click()   
    ' demonstrates getting the title from a demo Word document file
    MsgBox "Title: " & GetColumnDetail("C:\test2.doc", detailTitle)

    ' Further illustrates the power of this technique by getting info about a wav file
    MsgBox "Tooltip: " & GetColumnDetail("C:\WINNT\Media\notify.wav")
    MsgBox "Sample rate: " & GetColumnDetail("C:\WINNT\Media\notify.wav", detailAudioSampleRate)
End Sub[/blue]
 
Thanks Strongm,

I also discovered that it could be acheived using the DSOFile.dll

With the following declaration:-

Private m_oDocumentProps As DSOFile.OleDocumentProperties

and then this code...

Code:
Public Function GetPropTitle(sFile As String) As String

  Dim oSummProps As DSOFile.SummaryProperties
  Dim oCustProp As DSOFile.CustomProperty
  Dim fOpenReadOnly As Boolean
        
  Set m_oDocumentProps = New DSOFile.OleDocumentProperties
                
  m_oDocumentProps.Open sFile, fOpenReadOnly, dsoOptionOpenReadOnlyIfNoWriteAccess
                
  Set oSummProps = m_oDocumentProps.SummaryProperties
                
  GetPropTitle = oSummProps.Title
        
  Set oSummProps = Nothing
  Set m_oDocumentProps = Nothing

End Function

... I am able to get the title (as well as other info.)

Regards, Doug.
 
Absolutely. And we've discussed and recommended DSOFILE in this forum on numerous occassions in the past
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top