PC Review


Reply
Thread Tools Rate Thread

Count open workbooks before closing

 
 
=?Utf-8?B?TGVz?=
Guest
Posts: n/a
 
      22nd Jun 2007
Hi all, i am not a programmer but a dabbler and i am really stuck with
counting the open workbooks. I have a search programme in excel and i have in
the beginning of the code the following "Application.IgnoreRemoteRequests =
True" when i open other workbooks, no matter how many are open i always get
only 2 open with the code below ??

Sub chkWkb()

Dim wkb As Integer
Application.IgnoreRemoteRequests = False
Application.DisplayAlerts = True

wkb = Application.Workbooks.Count
If wkb < 2 Then
Application.Quit
Else
ActiveWorkbook.Close
End If

End Sub


Am i missing someghing here ??

--
Les
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      22nd Jun 2007
I don't, I get the correct answer!!

Mike

"Les" wrote:

> Hi all, i am not a programmer but a dabbler and i am really stuck with
> counting the open workbooks. I have a search programme in excel and i have in
> the beginning of the code the following "Application.IgnoreRemoteRequests =
> True" when i open other workbooks, no matter how many are open i always get
> only 2 open with the code below ??
>
> Sub chkWkb()
>
> Dim wkb As Integer
> Application.IgnoreRemoteRequests = False
> Application.DisplayAlerts = True
>
> wkb = Application.Workbooks.Count
> If wkb < 2 Then
> Application.Quit
> Else
> ActiveWorkbook.Close
> End If
>
> End Sub
>
>
> Am i missing someghing here ??
>
> --
> Les

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      25th Jun 2007
Les,
Not sure what you expect, but you do know what IgnoreRemoteRequests mean ?
As for the number of workbooks, I would guess one is the WB containing this
code and possibly the other is the hidden Personal.xls.

If you are opening other .xls files by double clicking them, they would open
in another instance of Excel. See point above.
If you use the File>Open or automation, they will open in this instance.

So, not enough to go on to give a real answer, but check the above and see
if they help.

NickHK

"Les" <(E-Mail Removed)> wrote in message
news:2FDFCE16-3D05-4245-832E-(E-Mail Removed)...
> Hi all, i am not a programmer but a dabbler and i am really stuck with
> counting the open workbooks. I have a search programme in excel and i have

in
> the beginning of the code the following "Application.IgnoreRemoteRequests

=
> True" when i open other workbooks, no matter how many are open i always

get
> only 2 open with the code below ??
>
> Sub chkWkb()
>
> Dim wkb As Integer
> Application.IgnoreRemoteRequests = False
> Application.DisplayAlerts = True
>
> wkb = Application.Workbooks.Count
> If wkb < 2 Then
> Application.Quit
> Else
> ActiveWorkbook.Close
> End If
>
> End Sub
>
>
> Am i missing someghing here ??
>
> --
> Les



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MACRO TO COUNT ALL OPEN WORKBOOKS and print JOSEPH WEBER Microsoft Excel Programming 1 11th May 2010 07:05 PM
Excel2007; workbooks.count is not counting all open workbooks greg.campeau Microsoft Excel Programming 2 2nd Aug 2008 08:37 PM
Multiple workbooks open -- closing workbooks =?Utf-8?B?SmFuZXQgUGFuaWdoZXR0aQ==?= Microsoft Excel Discussion 3 13th Nov 2007 05:43 PM
count number of workbooks open =?Utf-8?B?Um9uYWxkbw==?= Microsoft Excel Programming 2 21st Apr 2005 01:00 PM
How to close active Workbook without closing other open workbooks? =?Utf-8?B?RnJhbWluZ2hhbTE=?= Microsoft Excel Misc 1 19th Oct 2004 12:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:32 PM.