Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Is the list of Worksheets limited to "This Workbook"

Hi Excel wizs,

Is it possible to list the worksheets of a closed workbook? More !!! Is it
possible to list the worksheets of a number of closed workbooks ? ( the ones
in "C:\MyDocuments", for example)

Ideally, I would like to do it at runtime, but I could settle for a list
being updated by each new workbook created.

I hope I've been clear enough. If any of you's can put me on the right
track, I'd appreciate it.

Thanks,
Marc

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Is the list of Worksheets limited to "This Workbook"

Hi Marc

Bob posted this macro that use ADO to copy the sheet names of a closed workbook in the activesheet.

Sub GetSheetNames()
Dim objConn As Object
Dim objCat As Object
Dim tbl As Object
Dim iRow As Long
Dim sWorkbook As String
Dim sConnString As String
Dim sTableName As String
Dim cLength As Integer
Dim iTestPos As Integer
Dim iStartpos As Integer


sWorkbook = "c:\Data\test1.xls"
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sWorkbook & ";" & _
"Extended Properties=Excel 8.0;"


Set objConn = CreateObject("ADODB.Connection")
objConn.Open sConnString
Set objCat = CreateObject("ADOX.Catalog")
Set objCat.ActiveConnection = objConn


iRow = 1
For Each tbl In objCat.Tables
sTableName = tbl.Name
cLength = Len(sTableName)
iTestPos = 0
iStartpos = 1
'Worksheet name with embedded spaces enclosed by single quotes
If Left(sTableName, 1) = "'" And Right(sTableName, 1) = "'" Then
iTestPos = 1
iStartpos = 2
End If
'Worksheet names always end in the "$" character
If Mid$(sTableName, cLength - iTestPos, 1) = "$" Then
Cells(iRow, 1) = Mid$(sTableName, iStartpos, cLength - _
(iStartpos + iTestPos))
iRow = iRow + 1
End If
Next tbl
objConn.Close
Set objCat = Nothing
Set objConn = Nothing

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Marc Gendron" <Marc wrote in message ...
Hi Excel wizs,

Is it possible to list the worksheets of a closed workbook? More !!! Is it
possible to list the worksheets of a number of closed workbooks ? ( the ones
in "C:\MyDocuments", for example)

Ideally, I would like to do it at runtime, but I could settle for a list
being updated by each new workbook created.

I hope I've been clear enough. If any of you's can put me on the right
track, I'd appreciate it.

Thanks,
Marc



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Is the list of Worksheets limited to "This Workbook"

Thanks, you've been helpful.

(is this some kind of vocation for you or are you remunerated in some way?)

Thanks again
Marc


"Ron de Bruin" wrote:

Hi Marc

Bob posted this macro that use ADO to copy the sheet names of a closed workbook in the activesheet.

Sub GetSheetNames()
Dim objConn As Object
Dim objCat As Object
Dim tbl As Object
Dim iRow As Long
Dim sWorkbook As String
Dim sConnString As String
Dim sTableName As String
Dim cLength As Integer
Dim iTestPos As Integer
Dim iStartpos As Integer


sWorkbook = "c:\Data\test1.xls"
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sWorkbook & ";" & _
"Extended Properties=Excel 8.0;"


Set objConn = CreateObject("ADODB.Connection")
objConn.Open sConnString
Set objCat = CreateObject("ADOX.Catalog")
Set objCat.ActiveConnection = objConn


iRow = 1
For Each tbl In objCat.Tables
sTableName = tbl.Name
cLength = Len(sTableName)
iTestPos = 0
iStartpos = 1
'Worksheet name with embedded spaces enclosed by single quotes
If Left(sTableName, 1) = "'" And Right(sTableName, 1) = "'" Then
iTestPos = 1
iStartpos = 2
End If
'Worksheet names always end in the "$" character
If Mid$(sTableName, cLength - iTestPos, 1) = "$" Then
Cells(iRow, 1) = Mid$(sTableName, iStartpos, cLength - _
(iStartpos + iTestPos))
iRow = iRow + 1
End If
Next tbl
objConn.Close
Set objCat = Nothing
Set objConn = Nothing

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Marc Gendron" <Marc wrote in message ...
Hi Excel wizs,

Is it possible to list the worksheets of a closed workbook? More !!! Is it
possible to list the worksheets of a number of closed workbooks ? ( the ones
in "C:\MyDocuments", for example)

Ideally, I would like to do it at runtime, but I could settle for a list
being updated by each new workbook created.

I hope I've been clear enough. If any of you's can put me on the right
track, I'd appreciate it.

Thanks,
Marc




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Is the list of Worksheets limited to "This Workbook"

Hi Marc

No it is a Hobby and it is fun to help people

Have a nice day

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Marc Gendron" wrote in message ...
Thanks, you've been helpful.

(is this some kind of vocation for you or are you remunerated in some way?)

Thanks again
Marc


"Ron de Bruin" wrote:

Hi Marc

Bob posted this macro that use ADO to copy the sheet names of a closed workbook in the activesheet.

Sub GetSheetNames()
Dim objConn As Object
Dim objCat As Object
Dim tbl As Object
Dim iRow As Long
Dim sWorkbook As String
Dim sConnString As String
Dim sTableName As String
Dim cLength As Integer
Dim iTestPos As Integer
Dim iStartpos As Integer


sWorkbook = "c:\Data\test1.xls"
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sWorkbook & ";" & _
"Extended Properties=Excel 8.0;"


Set objConn = CreateObject("ADODB.Connection")
objConn.Open sConnString
Set objCat = CreateObject("ADOX.Catalog")
Set objCat.ActiveConnection = objConn


iRow = 1
For Each tbl In objCat.Tables
sTableName = tbl.Name
cLength = Len(sTableName)
iTestPos = 0
iStartpos = 1
'Worksheet name with embedded spaces enclosed by single quotes
If Left(sTableName, 1) = "'" And Right(sTableName, 1) = "'" Then
iTestPos = 1
iStartpos = 2
End If
'Worksheet names always end in the "$" character
If Mid$(sTableName, cLength - iTestPos, 1) = "$" Then
Cells(iRow, 1) = Mid$(sTableName, iStartpos, cLength - _
(iStartpos + iTestPos))
iRow = iRow + 1
End If
Next tbl
objConn.Close
Set objCat = Nothing
Set objConn = Nothing

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Marc Gendron" <Marc wrote in message
...
Hi Excel wizs,

Is it possible to list the worksheets of a closed workbook? More !!! Is it
possible to list the worksheets of a number of closed workbooks ? ( the ones
in "C:\MyDocuments", for example)

Ideally, I would like to do it at runtime, but I could settle for a list
being updated by each new workbook created.

I hope I've been clear enough. If any of you's can put me on the right
track, I'd appreciate it.

Thanks,
Marc








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Is the list of Worksheets limited to "This Workbook"

Marc

Ron does this just for the satisfaction he gains by helping others.

His day job is Chrysanthemum growing.


Gord

On Tue, 4 Jul 2006 13:56:01 -0700, Marc Gendron
wrote:

Thanks, you've been helpful.

(is this some kind of vocation for you or are you remunerated in some way?)

Thanks again
Marc


"Ron de Bruin" wrote:

Hi Marc

Bob posted this macro that use ADO to copy the sheet names of a closed workbook in the activesheet.

Sub GetSheetNames()
Dim objConn As Object
Dim objCat As Object
Dim tbl As Object
Dim iRow As Long
Dim sWorkbook As String
Dim sConnString As String
Dim sTableName As String
Dim cLength As Integer
Dim iTestPos As Integer
Dim iStartpos As Integer


sWorkbook = "c:\Data\test1.xls"
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & sWorkbook & ";" & _
"Extended Properties=Excel 8.0;"


Set objConn = CreateObject("ADODB.Connection")
objConn.Open sConnString
Set objCat = CreateObject("ADOX.Catalog")
Set objCat.ActiveConnection = objConn


iRow = 1
For Each tbl In objCat.Tables
sTableName = tbl.Name
cLength = Len(sTableName)
iTestPos = 0
iStartpos = 1
'Worksheet name with embedded spaces enclosed by single quotes
If Left(sTableName, 1) = "'" And Right(sTableName, 1) = "'" Then
iTestPos = 1
iStartpos = 2
End If
'Worksheet names always end in the "$" character
If Mid$(sTableName, cLength - iTestPos, 1) = "$" Then
Cells(iRow, 1) = Mid$(sTableName, iStartpos, cLength - _
(iStartpos + iTestPos))
iRow = iRow + 1
End If
Next tbl
objConn.Close
Set objCat = Nothing
Set objConn = Nothing

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Marc Gendron" <Marc wrote in message ...
Hi Excel wizs,

Is it possible to list the worksheets of a closed workbook? More !!! Is it
possible to list the worksheets of a number of closed workbooks ? ( the ones
in "C:\MyDocuments", for example)

Ideally, I would like to do it at runtime, but I could settle for a list
being updated by each new workbook created.

I hope I've been clear enough. If any of you's can put me on the right
track, I'd appreciate it.

Thanks,
Marc





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting "State" Column onto separate worksheets in same workbook. kjstec Excel Worksheet Functions 2 January 15th 08 07:59 PM
cannot use "Create List" and "Share Workbook" same time Devendra Excel Discussion (Misc queries) 0 October 26th 06 06:05 AM
Problem: Worksheets("New Style 2006").Unprotect Password:="naPrint" Karoo News[_2_] Excel Programming 1 January 30th 06 02:40 PM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM


All times are GMT +1. The time now is 11:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"