LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default getting worksheetnames from subfolders

hi,
I added below code, but I cannot see worksheet names from workbooks in sub
folders ? what is the problem ?

..SearchSubFolders = IncludeSubFolder

for example
I can get the names from d:\1\*.xls , d:\1\2\*.xls
but I cannot see the name of a worksheet in a.xls
d:\1\2\3\a.xls





If I want to see the directory of each worksheet next to the name of it how
can we revise the code?
for example;
book ( name of worksheet ) D:\library\...a.xls




Sub GetAllWorksheetNames()
Dim i As Integer
Dim wbResults As Workbook
Dim wbCodeBook As Workbook
Dim wSheet As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False

On Error Resume Next

Set wbCodeBook = ThisWorkbook

With Application.FileSearch
.NewSearch
.LookIn = "C:\my documents" 'amend to suit

.SearchSubFolders = IncludeSubFolder
.FileType = msoFileTypeExcelWorkbooks
If .Execute 0 Then
For i = 1 To .FoundFiles.Count
Set wbResults = Workbooks.Open(.FoundFiles(i))

wbCodeBook.Sheets(1).Range _
("A65536").End(xlUp)(2, 1) = UCase(wbResults.Name)
For Each wSheet In wbResults.Worksheets
wbCodeBook.Sheets(1).Range _
("A65536").End(xlUp)(2, 1) = wSheet.Name
Next wSheet
wbResults.Close SaveChanges:=False
Next i
End If
End With

On Error GoTo 0
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True
End Sub


--
SAHRAYICEDIT-ISTANBUL
 
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
Creating Subfolders MeTed Excel Programming 2 November 23rd 06 10:03 AM
Search through subfolders JustinP Excel Programming 4 September 5th 06 01:25 AM
Auto look through subfolders grewpp Charts and Charting in Excel 1 February 14th 06 02:35 PM
copy subfolders, replace text in files and save files in copied subfolders pieros Excel Programming 0 November 1st 05 12:08 PM
Get list of subfolders Darren Hill[_3_] Excel Programming 3 March 6th 05 09:28 PM


All times are GMT +1. The time now is 06:03 AM.

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

About Us

"It's about Microsoft Excel"