LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Loop through open workbooks

Hello,

Here is an idea for the second question:

Option Explicit

Public Sub LoopFiles()
Dim sStart As String
'
sStart = InputBox("Where to start", "Find Files in folder", "C:\My Documents")
loopTree (sStart)
End Sub


Private Sub loopTree(ByVal sStart As String)
Dim sFound As String
'
sFound = Dir(sStart & "\*.*")
Do While sFound < ""
If (GetAttr(sStart & "\" & sFound) And vbDirectory) = vbDirectory Then
loopTree (sStart & "\" & sFound)
Else
Debug.Print sStart & "\" & sFound
End If
sFound = Dir()
Loop
End Sub


Good Luck,

Wouter HM.

"Bob Phillips" wrote in message ...
For Each WB In Workbooks
Debug.Print WB.Name
Next WB

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Dan" wrote in message
...
Hello
What code would I use to loop through all open workbooks, or all files in

a dir names filex****.
Thanks!

 
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
IF wokkbook1 is open, open workbook2 Loop Fio[_2_] Excel Programming 1 March 5th 04 01:10 PM
Loop with two workbooks Mike Excel Programming 2 January 14th 04 07:15 PM
loop through workbooks Keith Willshaw Excel Programming 2 September 19th 03 12:48 PM
loop through workbooks Ron de Bruin Excel Programming 1 September 18th 03 02:53 PM
Can I have a loop to open a set of workbooks get some data, close it one a time. wellie Excel Programming 2 July 9th 03 04:58 AM


All times are GMT +1. The time now is 06:51 PM.

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"