View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Keith Willshaw Keith Willshaw is offline
external usenet poster
 
Posts: 170
Default Worksheets and arrays


"Nick" wrote in message
...
Given a variable that is a filename does anyone know how
to retrieve a list of all worksheets within that file and
place them in an array?

I eventually want the list to appear in a combo box so I
am assuming an array is the easiest way of doing this.


Not necessarily


Any suggestions would be greatly appreciated



This code should do the job nicely

Dim xlbook as Workbook , xlsheet as Worksheet

Set xlbook = xlapp.Workbooks.Open(wkbname)
For Each xlsheet in xlbook.Worksheets
myComboBox.Additem xlsheet.name
Next xlsheet

xlbook.Close

Keith