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

API to get excel file information

Status
Not open for further replies.

nimrod44

Programmer
Sep 17, 2001
7
0
0
US
I am trying to use API call via Visual Basic 6.0 to access Excel 2000 file properties. I have a program that opens an excel template we have built and up until now it has not been a problem. Now our customer(s) are requesting custom templates so I need a method of identifying a template before the program opens. Is there an API call that will access excel file properties. I'd like to use either the Summary, or Custom file properties you see when you right click on an excel file and goto properties menu item. I'd really like to use the Custom properties so I can more customize the properties, but if I can access the Summary properties this will work just fine.
Thanks for help anybody can provide.
Darrel
 
Hi nimrod44,

Try this:


Dim Excel As Excel.Application
Dim i As Long

On Error Resume Next

Set Excel = New Excel.Application
With Excel.Workbooks.Open("C:\test.xls")
' File Properties
For i = 1 To .BuiltinDocumentProperties.Count
Debug.Print .BuiltinDocumentProperties(i).Name & _
" = " & .BuiltinDocumentProperties(i).Value
Next
' Custom Properties
For i = 1 To .CustomDocumentProperties.Count
Debug.Print .CustomDocumentProperties(i).Name & _
" = " & .CustomDocumentProperties(i).Value
Next
End With
Excel.Quit

Bye
LauDse
 
you could try recording a macro of the operation, view the results in the editor.

you could also use the object browser in visual basic to view the properties and methods of excel. I use the object browser to help in viewing object modules all the time in programming automated applications. Attitude is Everything
 
use shellexecuteex() function, it will certainly solve ur problem
Tushar Bhatnagar
t_bhatnagar@sify.com
 
have you tried using the object browser in visual basic.
once in object browser select excel from drop down list. if not in list go to tools -> references and load excel.

once in excel you can view all properties and methods. Attitude is Everything
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top