Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Use Array to activate workbooks

The following code works fine, in a situation where the workbooks
are originally opened, worked on, and then closed. FilesArray
holds the names of the previously opened workbooks, and can be
used again to open the books:

If FileCounter 0 Then
Application.ScreenUpdating = False
For LoopCounter = 1 To FileCounter
Workbooks.Open vFilename & FilesArray(LoopCounter), False

In a slightly different situation, the books are still open. Can I modify
the
code and use FilesArray to activate them in turn?

What I'd like to say, is:
Workbooks.Activate vFilename & FilesArray(LoopCounter), False
but that is not supported (Excel2000).

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Use Array to activate workbooks

if filesarray contains just the name of the workbook and not the path
ex: myworkbook.xls vice c:\myfiles\myworkbook.xls

then you can

Workbooks(filesarray(counter)).Activate

Do you know they are all open or do you need to text and either if open,
then activate or if not open open and activate?

--
regards,
Tom Ogilvy

"Stuart" wrote in message
...
The following code works fine, in a situation where the workbooks
are originally opened, worked on, and then closed. FilesArray
holds the names of the previously opened workbooks, and can be
used again to open the books:

If FileCounter 0 Then
Application.ScreenUpdating = False
For LoopCounter = 1 To FileCounter
Workbooks.Open vFilename & FilesArray(LoopCounter), False

In a slightly different situation, the books are still open. Can I modify
the
code and use FilesArray to activate them in turn?

What I'd like to say, is:
Workbooks.Activate vFilename & FilesArray(LoopCounter), False
but that is not supported (Excel2000).

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Use Array to activate workbooks

Stuart,

For XL2000 onward, where InStrRev exists:

Dim myName As String

For LoopCounter = LBound(FilesArray) to UBound(FilesArray)

myName = FilesArray(LoopCounter)
Workbooks(Mid(myName, InStrRev(myName, "\") + 1)).Activate
'Do other stuff here

Next LoopCounter

HTH,
Bernie
MS Excel MVP

"Stuart" wrote in message
...
The following code works fine, in a situation where the workbooks
are originally opened, worked on, and then closed. FilesArray
holds the names of the previously opened workbooks, and can be
used again to open the books:

If FileCounter 0 Then
Application.ScreenUpdating = False
For LoopCounter = 1 To FileCounter
Workbooks.Open vFilename & FilesArray(LoopCounter), False

In a slightly different situation, the books are still open. Can I

modify
the
code and use FilesArray to activate them in turn?

What I'd like to say, is:
Workbooks.Activate vFilename & FilesArray(LoopCounter),

False
but that is not supported (Excel2000).

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Use Array to activate workbooks

Many thanks to you both. Will look at your solutions.

Yes, FilesArray holds only the book names, not the path.

I will need to post back here, I fear.

Regards and thanks, both.

"Tom Ogilvy" wrote in message
...
if filesarray contains just the name of the workbook and not the path
ex: myworkbook.xls vice c:\myfiles\myworkbook.xls

then you can

Workbooks(filesarray(counter)).Activate

Do you know they are all open or do you need to text and either if open,
then activate or if not open open and activate?

--
regards,
Tom Ogilvy

"Stuart" wrote in message
...
The following code works fine, in a situation where the workbooks
are originally opened, worked on, and then closed. FilesArray
holds the names of the previously opened workbooks, and can be
used again to open the books:

If FileCounter 0 Then
Application.ScreenUpdating = False
For LoopCounter = 1 To FileCounter
Workbooks.Open vFilename & FilesArray(LoopCounter), False

In a slightly different situation, the books are still open. Can I

modify
the
code and use FilesArray to activate them in turn?

What I'd like to say, is:
Workbooks.Activate vFilename & FilesArray(LoopCounter), False
but that is not supported (Excel2000).

Regards.



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003


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
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
How do I activate the xls feature to combine and compare workbooks Boogy Setting up and Configuration of Excel 1 September 20th 06 11:38 PM
Workbooks(WorkbookName).Activate Failure [email protected] Charts and Charting in Excel 2 July 16th 06 12:14 PM
how do I activate links without opening external workbooks? teh_chucksta Excel Discussion (Misc queries) 0 August 29th 05 11:22 PM


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