ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening all files located in a specific directory (https://www.excelbanter.com/excel-programming/321493-opening-all-files-located-specific-directory.html)

DaSo

Opening all files located in a specific directory
 
Hi everybody,

Having done just a few macros for Excel, I´m a total beginner in VB and
I would like to ask you how to open all files located in a specific
directories at once. I thought the following might work, but it doesn´t:

Sub Makro1()

ChDir "C:\user\Results"
Workbooks.Open FileName:="*.*"

End Sub


Any help?




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom Ogilvy

Opening all files located in a specific directory
 
Sub Makro1()

ChDir "C:\user\Results"
fName = Dir("C:\user\Results\*.xls")
do while fName < ""
workbooks.Open fName
fName = dir()
Loop

End Sub

Assumes you don't have any directories with a .xls extension.

--
Regards,
Tom Ogilvy



"DaSo" wrote in message
...
Hi everybody,

Having done just a few macros for Excel, I´m a total beginner in VB and
I would like to ask you how to open all files located in a specific
directories at once. I thought the following might work, but it doesn´t:

Sub Makro1()

ChDir "C:\user\Results"
Workbooks.Open FileName:="*.*"

End Sub


Any help?




*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!




DaSo

Opening all files located in a specific directory
 
Thanks and regards to Tom Ogilvy, problem solved.
Dan



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 08:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com