#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default New to VBA

Dear All,

Please help..i have the module like this:

For Each wSheet In ActiveWorkbook.Worksheets....it works when the file is
open.

How to replace "ActiveWorkbook" with the closed file for this details:
c:\data\AAA.xls.

thank you for your kind attention and help.

respectfully,
Andri
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default New to VBA

That does not work with a closed workbook. While there are some techniques to
deal with closed workbooks they generally require that you know the structure
of the workbook. You can not just traverse all of the sheets. You need to
reference them one at a time by index number of name.

My recommendation is to open the workbook...
--
HTH...

Jim Thomlinson


"Andri" wrote:

Dear All,

Please help..i have the module like this:

For Each wSheet In ActiveWorkbook.Worksheets....it works when the file is
open.

How to replace "ActiveWorkbook" with the closed file for this details:
c:\data\AAA.xls.

thank you for your kind attention and help.

respectfully,
Andri

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default New to VBA

Dear Jim,

Point taken...thank you.

Ok, i will open these two files:

1. AAA.xls (contains that module), successfully to VLOOKUP all the sheets in
this file.
2. BBB.xls (now i would like to use that module to do Vlookup to this
BBB.xls).

Please guide to to reference "ActiveWorkbook" to the workbook in BBB.xls.

Respectfully,
Andri

"Jim Thomlinson" wrote:

That does not work with a closed workbook. While there are some techniques to
deal with closed workbooks they generally require that you know the structure
of the workbook. You can not just traverse all of the sheets. You need to
reference them one at a time by index number of name.

My recommendation is to open the workbook...
--
HTH...

Jim Thomlinson


"Andri" wrote:

Dear All,

Please help..i have the module like this:

For Each wSheet In ActiveWorkbook.Worksheets....it works when the file is
open.

How to replace "ActiveWorkbook" with the closed file for this details:
c:\data\AAA.xls.

thank you for your kind attention and help.

respectfully,
Andri

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default New to VBA

Try something like

Dim oWB as workbook
'---
Set oWB = Workbooks.open(filename:="c:\data\BBB.xls")
For Each wSheet In oWB.Worksheets
'stuff
Next
oWB.saved = true
oWB.close

HTH. Best wishes Harald

"Andri" skrev i melding
...
Dear Jim,

Point taken...thank you.

Ok, i will open these two files:

1. AAA.xls (contains that module), successfully to VLOOKUP all the sheets
in
this file.
2. BBB.xls (now i would like to use that module to do Vlookup to this
BBB.xls).

Please guide to to reference "ActiveWorkbook" to the workbook in BBB.xls.

Respectfully,
Andri

"Jim Thomlinson" wrote:

That does not work with a closed workbook. While there are some
techniques to
deal with closed workbooks they generally require that you know the
structure
of the workbook. You can not just traverse all of the sheets. You need to
reference them one at a time by index number of name.

My recommendation is to open the workbook...
--
HTH...

Jim Thomlinson


"Andri" wrote:

Dear All,

Please help..i have the module like this:

For Each wSheet In ActiveWorkbook.Worksheets....it works when the file
is
open.

How to replace "ActiveWorkbook" with the closed file for this details:
c:\data\AAA.xls.

thank you for your kind attention and help.

respectfully,
Andri



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



All times are GMT +1. The time now is 03:09 PM.

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"