Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default Opening Workbooks in a Folder

Hello All,
I would like to open each workbook in a folder, get some information from it
and close it. How can that be done? I can get the path but when I do
workbooks count, it just counts the open workbooks.

Thanks,

Bill


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Opening Workbooks in a Folder

Hi Bill,

See Ron de Bruin's sample code at:

http://www.rondebruin.nl/ado.htm

and

http://www.rondebruin.nl/copy7.htm

See also Ro's index page at:

http://www.rondebruin.nl/tips.htm


---
Regards,
Norman



"Bill" wrote in message
k.net...
Hello All,
I would like to open each workbook in a folder, get some information from
it and close it. How can that be done? I can get the path but when I do
workbooks count, it just counts the open workbooks.

Thanks,

Bill



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Opening Workbooks in a Folder

On Thu, 29 Jun 2006 13:33:46 GMT, Bill wrote:

Hello All,
I would like to open each workbook in a folder, get some information from it
and close it. How can that be done? I can get the path but when I do
workbooks count, it just counts the open workbooks.

Thanks,

Bill


Test this sample module:

Option Explicit

Function GetAllXLSFiles(ByVal strFolder As String) As Variant
Dim strCurFile As String
Dim strTmp As String
strCurFile = Dir(strFolder & "\*.xls")
Do While strCurFile < ""
strTmp = strTmp & Switch(strTmp = "", "", True, ";") & strCurFile
strCurFile = Dir
Loop
GetAllXLSFiles = Split(strTmp, ";")
End Function

Sub test()
Dim v As Variant
v = GetAllXLSFiles("d:\somefolder")
End Sub
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Opening Workbooks in a Folder

Piotr, how would I amend your Function to include subfolders and only
open the last modified file in each subfolder. TIA

Greg
Piotr Lipski wrote:
On Thu, 29 Jun 2006 13:33:46 GMT, Bill wrote:

Hello All,
I would like to open each workbook in a folder, get some information from it
and close it. How can that be done? I can get the path but when I do
workbooks count, it just counts the open workbooks.

Thanks,

Bill


Test this sample module:

Option Explicit

Function GetAllXLSFiles(ByVal strFolder As String) As Variant
Dim strCurFile As String
Dim strTmp As String
strCurFile = Dir(strFolder & "\*.xls")
Do While strCurFile < ""
strTmp = strTmp & Switch(strTmp = "", "", True, ";") & strCurFile
strCurFile = Dir
Loop
GetAllXLSFiles = Split(strTmp, ";")
End Function

Sub test()
Dim v As Variant
v = GetAllXLSFiles("d:\somefolder")
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Opening Workbooks in a Folder

Dnia 29 Jun 2006 08:33:58 -0700, GregR napisał(a):

Piotr, how would I amend your Function to include subfolders and only
open the last modified file in each subfolder. TIA


Dealing with subfolders is not trivial when using Dir function (it cannot
be used recursively). You should probably read about FileScripting library
(or sth like that) - I've never used it, but recurring throught subfolders
is quite common task. Google should be helpful ;)

--
PL


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Opening Workbooks in a Folder

See
http://www.rondebruin.nl/copy3.htm

Number 1


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



"Piotr Lipski" wrote in message ...
Dnia 29 Jun 2006 08:33:58 -0700, GregR napisał(a):

Piotr, how would I amend your Function to include subfolders and only
open the last modified file in each subfolder. TIA


Dealing with subfolders is not trivial when using Dir function (it cannot
be used recursively). You should probably read about FileScripting library
(or sth like that) - I've never used it, but recurring throught subfolders
is quite common task. Google should be helpful ;)

--
PL



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
For all workbooks in a folder Ctech[_89_] Excel Programming 3 January 31st 06 04:14 PM
Opening a folder Daminc[_29_] Excel Programming 12 January 23rd 06 11:47 AM
when opening folder Brian Thompson via OfficeKB.com New Users to Excel 2 December 18th 05 10:50 PM
Opening Workbooks in a Folder One by One Chris Gorham Excel Programming 1 November 22nd 05 08:54 AM
"Folder Select" Dialogue - Opening multiple files from selected folder Rob[_26_] Excel Programming 2 September 30th 05 02:47 PM


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