Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Count open workbooks before closing

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Count open workbooks before closing

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Count open workbooks before closing

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 FileOpen 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" wrote in message
...
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
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
Closing workbooks w/o closing Excel Barb in MD Excel Discussion (Misc queries) 3 February 15th 10 06:42 PM
count number of workbooks open Ronaldo Excel Programming 2 April 21st 05 01:00 PM
How do I stop Excel from closing the open file each time I open a. Welsin Setting up and Configuration of Excel 3 January 8th 05 11:16 PM
Closing Other Workbooks Tim Mayes[_2_] Excel Programming 4 December 13th 04 11:08 PM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM


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