Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jC! jC! is offline
external usenet poster
 
Posts: 10
Default list Workbooks in Current Folder

hi all,

your help is mostly appreciated for following:

i have a dedicated folder (called "Project" for example) which has
following Workbooks:

Workbook1
Workbook2
Workbook3
and most important
MasterWorkbook

now i would like to have a macro which is executed in the
MasterWorkbook that will generate the list of all the Workbooks in the
folder where the MasterWorkbook resides ("Project" folder in this
example) except for the MasterWorkbook itself on a specific sheet
(called "Workbook Overview" for example).

in this example on MasterWorkbook.Workbook Overview the list would be
as follow:
Workbook1
Workbook2
Workbook3

thanking you for your time - cheers...


....jurgenC!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default list Workbooks in Current Folder

Try this, it assumes your "MasterWorkbook" is the ActiveWorkbook :

Sub listProjectFiles()
Sheets.Add
myFile = Dir(ActiveWorkbook.Path & "\*.xls")
i = 1
Do While myFile < ""
If myFile < ActiveWorkbook.Name Then
Cells(i, 1) = myFile
i = i + 1
End If
myFile = Dir
Loop
End Sub

....Chris

"jC!" wrote in message
om...
hi all,

your help is mostly appreciated for following:

i have a dedicated folder (called "Project" for example) which has
following Workbooks:

Workbook1
Workbook2
Workbook3
and most important
MasterWorkbook

now i would like to have a macro which is executed in the
MasterWorkbook that will generate the list of all the Workbooks in the
folder where the MasterWorkbook resides ("Project" folder in this
example) except for the MasterWorkbook itself on a specific sheet
(called "Workbook Overview" for example).

in this example on MasterWorkbook.Workbook Overview the list would be
as follow:
Workbook1
Workbook2
Workbook3

thanking you for your time - cheers...


...jurgenC!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default list Workbooks in Current Folder

hi Chris,

exaclty what i wanted.

thanks for your help and time.

cheers....


...jurgenC!

remove "somewhere" from eMail when replying direct

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default list Workbooks in Current Folder

Hi jurgenC

something like that (not very elegant, but it seeems to
work):

Sub FindAllWorkbooks()

Dim strBook As String

ThisWorkbook.Worksheets("Workbook Overview").Select
Range("a1").Select
strBook = Dir("c:\project\*.xls", vbDirectory)
ActiveCell.Value = strBook
Do While strBook < ""
strBook = Dir
If strBook < "MasterWorkbook" Then
ActiveCell.Value = strBook
ActiveCell.Offset(1, 0).Select
End If
Loop

'if you want to sort it
Range("a:a").Sort key1:=Range("a1")
Range("a1").Select

End Sub


Best regards

Wolf

WLamik<atgmx.net

-----Original Message-----
hi all,

your help is mostly appreciated for following:

i have a dedicated folder (called "Project" for example)

which has
following Workbooks:

Workbook1
Workbook2
Workbook3
and most important
MasterWorkbook

now i would like to have a macro which is executed in the
MasterWorkbook that will generate the list of all the

Workbooks in the
folder where the MasterWorkbook resides ("Project" folder

in this
example) except for the MasterWorkbook itself on a

specific sheet
(called "Workbook Overview" for example).

in this example on MasterWorkbook.Workbook Overview the

list would be
as follow:
Workbook1
Workbook2
Workbook3

thanking you for your time - cheers...


....jurgenC!
.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default list Workbooks in Current Folder

Hi Wolf,

thanks for your solution and especially the sorting routine.

find following the code which i use now for my Worksheet:

Sub listProjectFiles()
Dim myFile As String
Dim i As Integer
myFile = Dir(ActiveWorkbook.Path & "\*.xls")
i = 1
Do While myFile < ""
If myFile < ActiveWorkbook.Name Then
If myFile Like "TestCas*(*" Then
Range("TestCasesOverview").Offset(i, 0) = myFile
i = i + 1
End If
End If
myFile = Dir
Loop
End Sub

this works like a charm, if for example the folder has follwoing XLS
files:
TestPlan
TestCases (test)
TestCases template
and i execute (from TestPlan the mastersheet), i receive following list:
TestCases (test)

- i am somewhat perplexed though when trying to shorten the above code
to following:

Sub listProjectFiles()
Dim myFile As String
Dim i As Integer
myFile = Dir(ActiveWorkbook.Path & "\*.xls")
i = 1
Do While myFile < ""
If myFile < ActiveWorkbook.Name or myFile < "*template" Then
Range("TestCasesOverview").Offset(i, 0) = myFile
i = i + 1
End If
myFile = Dir
Loop
End Sub

i then receive following list:
TestCases (test)
TestCases template

however, i am trying to omit 'TestCases template'

it is not a major concern but would be great to understand where my
logic is taking a wrong turn

cheers....

....jurgenC!

remove "somewhere" from eMail when replying direct

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
use current file and folder name mohavv Excel Discussion (Misc queries) 1 December 19th 07 10:06 PM
extract from multiple workbooks in a folder smonsmo Excel Discussion (Misc queries) 8 August 19th 07 09:57 PM
Macro to open most current file in folder Tasha Excel Discussion (Misc queries) 6 June 19th 07 03:36 PM
Macro syntax to open file in current explorer folder [email protected] Excel Discussion (Misc queries) 4 January 11th 06 12:07 PM
Excel should open documents in the folder of the current file boxfactory Setting up and Configuration of Excel 0 October 20th 05 03:35 PM


All times are GMT +1. The time now is 07: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"