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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

displaying file properties

Status
Not open for further replies.

simoncpage

Programmer
Apr 4, 2002
256
GB
I have the following function that works fine for activeworkbooks how do I display the properties of a file that isn't open but one which I have selected? (or typed in the path of in a txtbox?)

Thanks
Simon
-------------------
Function ListBuiltInProps(lstListBox As MSForms.ListBox, _
strFileName As String)

Dim prpDocProp As DocumentProperty
Dim colPropsColl As DocumentProperties

Select Case mstrAppName
Case "Microsoft Excel"
Set colPropsColl = Excel.Application.ActiveWorkbook.BuiltinDocumentProperties
'Case "Microsoft Word"
' Set colPropsColl = Word.Application.ActiveDocument.BuiltinDocumentProperties
'Case "Microsoft PowerPoint"
' Set colPropsColl = PowerPoint.Application.ActivePresentation.BuiltinDocumentProperties
Case Else
End Select
On Error Resume Next
lstListBox.Clear
For Each prpDocProp In colPropsColl
lstListBox.AddItem prpDocProp.Name & " = " & prpDocProp.Value
Next prpDocProp
End Function
 
try something like...

Code:
Option Explicit

Private Sub Command1_Click()
  Dim oWB As Excel.Workbook
  Set oWB = GetObject("C:\WINDOWS\Profiles\K26479\My Documents\TEST.xls")
  
  ListBuiltInProps oWB
  
  Set oWB = Nothing
End Sub

Private Function ListBuiltInProps(oWB As Excel.Workbook)
  Dim prpDocProp
  Dim colPropsColl
  
  Set colPropsColl = oWB.BuiltinDocumentProperties
  
  On Error Resume Next
  For Each prpDocProp In colPropsColl
    Debug.Print prpDocProp.Name & " = " & prpDocProp.Value
  Next prpDocProp
End Function
 
I was trying something along those line but I have decided to use the dsofile.dll thanks alot anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top