View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
RobinG RobinG is offline
external usenet poster
 
Posts: 4
Default Opening Multiple Workbooks from a macro with a twist

I have a button with a macro attached in a seperate workbook that opens 9
different workbooks ranging from 3 Mb to 29 Mb, refreshes them, saves and
closes

This is part of my code

ChDir "\\Usnt36\nalogistics\Nato rail\REPORTS\RFMS Access
Database\Metrics database"

Workbooks.Open Filename:="\\USNT36\nalogistics\Nato Rail\Reports\RFMS
Access Database\Metrics Database\Metrics Total Plastics Fleet.xls", _
WriteResPassword:="rfms", Password:="rfms"
ActiveWorkbook.RefreshAll
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Save
ActiveWorkbook.Close

Workbooks.Open Filename:="\\USNT36\nalogistics\Nato Rail\Reports\RFMS
Access Database\Metrics Database\Metrics Total Tank & Hopper Car Fleet.xls", _
WriteResPassword:="rfms", Password:="rfms"
ActiveWorkbook.RefreshAll
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Save
ActiveWorkbook.Close

etc... for each workbook. It works like a charm.

"Tom Ogilvy" wrote:

If you doing more than reading data from the files, you will need to open
them.

--
Regards,
Tom Ogilvy

"Doug" wrote in message
...
I have 5 large excel files approx 12Mb each in a folder and I am trying to
access them programmatically from another excel file in the same directory

(a
report template). When I call code to open them like

Workbooks.Open Filename:=sName (thanks tom) it takes a very long time,

like
the computer is running out of memory. Is there a way for excel to access

the
Workbook-Worksheet programmatically without actually opening the excel

file?

I need to process all of the excel files from a separate one rather than
sticking the same macro in each file.

this is doing my head in
Any help greatly appreciated
Cheers
Doug