Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Test for open workbook


I'm having a few problems when one workbook is open, then another
containing macros is opened (while the first is still open). The
macro's cease up in this situation and they do funny things.

So, I am wondering if there is a test procedure to check if there is a
workbook open, and if so, then I can send a

Sub TestWrkBks()
* If...'OtherWorkbooksAreOpen?'...Then
MsgBox "Please close all other workbooks and try again"
ActiveWorkbook.Close
End if
End Sub

Any assistance would be much appreciated.

Kartune85


--
kartune85
------------------------------------------------------------------------
kartune85's Profile: http://www.excelforum.com/member.php...o&userid=35586
View this thread: http://www.excelforum.com/showthread...hreadid=554374

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Test for open workbook

kartune85,
If other workbooks cause problems, it is probably because your code is not
clearly working only on ThisWorkbook.

If you add a
With ThisWorkbook
With .Worksheets(Whatever)
.Range(.....

other workbooks should not have an effect.

NickHK

"kartune85" wrote
in message ...

I'm having a few problems when one workbook is open, then another
containing macros is opened (while the first is still open). The
macro's cease up in this situation and they do funny things.

So, I am wondering if there is a test procedure to check if there is a
workbook open, and if so, then I can send a

Sub TestWrkBks()
* If...'OtherWorkbooksAreOpen?'...Then
MsgBox "Please close all other workbooks and try again"
ActiveWorkbook.Close
End if
End Sub

Any assistance would be much appreciated.

Kartune85


--
kartune85
------------------------------------------------------------------------
kartune85's Profile:

http://www.excelforum.com/member.php...o&userid=35586
View this thread: http://www.excelforum.com/showthread...hreadid=554374



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Test for open workbook


Thanks for the advice NickHK.

Altho I've still got a slight problem with that I've used
"ThisWorkbook" but from my code I've created a second workbook which is
automatically named "Book1, Book2, Book3..." and I've got code in
"ThisWorkbook" that moves a sheet from itself to the newly created
workbook.

There's a conflict when someone tries to start a new Workbook while
another one is still open and then "ThisWorkbook" tries to move a sheet
from itself to "Workbooks(2)". Thus the confusion cause I think it gets
confused as to which one is "Workbooks(2)" (Book1 or OldBook).

How can I refer to the newly created workbook without it getting
confused with other workbooks that are already opened?

If there is some kind of testing procedure to stop the workbook from
opening if there's others open would come in quite handy.

Kartune85


--
kartune85
------------------------------------------------------------------------
kartune85's Profile: http://www.excelforum.com/member.php...o&userid=35586
View this thread: http://www.excelforum.com/showthread...hreadid=554374

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Test for open workbook

kartune85,
Dim NewWB As WorkBook
Set NewWB=Workbook.Add (..../ Workbook.Open (....

Now you can use this reference to the newly added WB in subsequent code and
it does not matter how many other WBs are open. e.g
NewWB.Worksheets(1).Range....

NickHK

"kartune85" wrote
in message ...

Thanks for the advice NickHK.

Altho I've still got a slight problem with that I've used
"ThisWorkbook" but from my code I've created a second workbook which is
automatically named "Book1, Book2, Book3..." and I've got code in
"ThisWorkbook" that moves a sheet from itself to the newly created
workbook.

There's a conflict when someone tries to start a new Workbook while
another one is still open and then "ThisWorkbook" tries to move a sheet
from itself to "Workbooks(2)". Thus the confusion cause I think it gets
confused as to which one is "Workbooks(2)" (Book1 or OldBook).

How can I refer to the newly created workbook without it getting
confused with other workbooks that are already opened?

If there is some kind of testing procedure to stop the workbook from
opening if there's others open would come in quite handy.

Kartune85


--
kartune85
------------------------------------------------------------------------
kartune85's Profile:

http://www.excelforum.com/member.php...o&userid=35586
View this thread: http://www.excelforum.com/showthread...hreadid=554374



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
Test to see if a workbook is open Brettjg Excel Discussion (Misc queries) 1 March 5th 07 09:26 AM
Test to see if a workbook is open Alex St-Pierre Excel Programming 3 February 17th 05 05:40 PM
Test if a workbook is open already Kieran1028[_17_] Excel Programming 7 November 22nd 04 08:13 PM
Test that a workbook is open Gef[_2_] Excel Programming 2 April 6th 04 11:17 AM
test for workbook open Rich C Excel Programming 1 March 1st 04 02:52 PM


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