How do I get the file properties?

  • Thread starter Thread starter Guy Cohen
  • Start date Start date
G

Guy Cohen

Hi all,

I use VB6 to read/fill an Excel file.
I would like to get the properties of the file.

The fields I need are:
From Excel:When you click "File"->"Properties" you have:
Subject + Author on the second tab.
Client on the fifth tab.

Please advise.

Guy
 
Guy,

Here's an Excel way of doing it.

Sub test()
Dim strSubject As String, strAuthor As String, strClient As String

On Error Resume Next
With ActiveWorkbook.BuiltinDocumentProperties
strSubject = .Item("Subject").Value
strAuthor = .Item("Author").Value
End With
With ActiveWorkbook.CustomDocumentProperties
strClient = .Item("Client").Value
End With
On Error GoTo 0

MsgBox "Subject: " & strSubject & vbNewLine & _
"Author: " & strAuthor & vbNewLine & _
"Client: " & strClient
End Sub
 
Hi Rob
Thank you for the reply.
I was just about to post that I found it :)
However - my code is a bit different than yours.
I use:
xlsApp.ActiveWorkbook.CustomDocumentProperties(5)
To get the client.
My Excel is in Hebrew so if I reference ("Client") I get an error.
However if I write the Hebrew word for client I get the client OK.

So my new question is- Will "Client" always stay here:
CustomDocumentProperties(5)
??

TIA
Guy
 
Guy,

You cannot assume that client will always be index 5. If one of the lower
index properties is deleted, then the rest will take up the gap, thereby
changing index.

Always best to use the name.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Guy,

It's not in position 5 on my computer... which raises an interesting
problem.
Looks like if you want to use both, you may have to do lanuage checks up
front.
 
Back
Top