count sheets

L

Lord Kelvan

i am guessing you are using this from access if so you have to set up
an application object and what not if you havent done so already

'opens workbook
Dim objexcel As New Excel.Application
Set objexcel = CreateObject("Excel.Application")
objexcel.Workbooks.Open "c:/path of workbook/workbook name.xls"
objexcel.Visible = True
'counts sheets
msgbox objexcel.Sheets.Count

if you are in the wrong group and should be in an excel group use

ActiveWorkbook.Sheets.Count

hope this helps

Regards
Kelvan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top