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

Hi,

I'm building a database and part of it launches an excel workbook.

Before closing my workbook I'd like to check if there are any other
workbooks open (that the user may be using). If there are no workbooks open
I'd like to completely close Excel, otherwise just close my workbook.

The snag is, I won't know the file names of the other workbooks.

Is there any way you can check for open workbooks without knowing there name?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Check for open workbooks

Hi Steve

If you don't have a hidden personal.xls you can use this

If Application.Workbooks.Count = 1 Then
MsgBox "your close code"
End If

If you have a personal.xls file then you must check for visiblw workbooks
If you need help post back


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steve Price" wrote in message ...
Hi,

I'm building a database and part of it launches an excel workbook.

Before closing my workbook I'd like to check if there are any other
workbooks open (that the user may be using). If there are no workbooks open
I'd like to completely close Excel, otherwise just close my workbook.

The snag is, I won't know the file names of the other workbooks.

Is there any way you can check for open workbooks without knowing there name?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Check for open workbooks

oxlApp.workbooks.count

or


cnt = 0
for each wkbk in oxlApp.workbooks
if wkbk.windows(1).Visible then
cnt = cnt + 1
end if
Next


--
Regards,
Tom Ogilvy


"Steve Price" wrote in message
...
Hi,

I'm building a database and part of it launches an excel workbook.

Before closing my workbook I'd like to check if there are any other
workbooks open (that the user may be using). If there are no workbooks

open
I'd like to completely close Excel, otherwise just close my workbook.

The snag is, I won't know the file names of the other workbooks.

Is there any way you can check for open workbooks without knowing there

name?

Thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Check for open workbooks

Thanks for the quick reply.

The database is going to be used by approx 30 users so is it possible that
some would have the personal.xls and some wouldn't? If so, how would I
overcome this.

Thanks again.

"Ron de Bruin" wrote:

Hi Steve

If you don't have a hidden personal.xls you can use this

If Application.Workbooks.Count = 1 Then
MsgBox "your close code"
End If

If you have a personal.xls file then you must check for visiblw workbooks
If you need help post back


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steve Price" wrote in message ...
Hi,

I'm building a database and part of it launches an excel workbook.

Before closing my workbook I'd like to check if there are any other
workbooks open (that the user may be using). If there are no workbooks open
I'd like to completely close Excel, otherwise just close my workbook.

The snag is, I won't know the file names of the other workbooks.

Is there any way you can check for open workbooks without knowing there name?

Thanks




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Check for open workbooks

Hi Steve

Tom have give you a example in his reply

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steve Price" wrote in message ...
Thanks for the quick reply.

The database is going to be used by approx 30 users so is it possible that
some would have the personal.xls and some wouldn't? If so, how would I
overcome this.

Thanks again.

"Ron de Bruin" wrote:

Hi Steve

If you don't have a hidden personal.xls you can use this

If Application.Workbooks.Count = 1 Then
MsgBox "your close code"
End If

If you have a personal.xls file then you must check for visiblw workbooks
If you need help post back


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steve Price" wrote in message ...
Hi,

I'm building a database and part of it launches an excel workbook.

Before closing my workbook I'd like to check if there are any other
workbooks open (that the user may be using). If there are no workbooks open
I'd like to completely close Excel, otherwise just close my workbook.

The snag is, I won't know the file names of the other workbooks.

Is there any way you can check for open workbooks without knowing there name?

Thanks








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Check for open workbooks

Personal.xls is not opened if you open excel using automation. From you
description, it is hard to tell exactly what you situation is, but I
provided code to check for visible workbooks.

--
Regards,
Tom Ogilvy

"Steve Price" wrote in message
...
Thanks for the quick reply.

The database is going to be used by approx 30 users so is it possible that
some would have the personal.xls and some wouldn't? If so, how would I
overcome this.

Thanks again.

"Ron de Bruin" wrote:

Hi Steve

If you don't have a hidden personal.xls you can use this

If Application.Workbooks.Count = 1 Then
MsgBox "your close code"
End If

If you have a personal.xls file then you must check for visiblw

workbooks
If you need help post back


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Steve Price" wrote in message

...
Hi,

I'm building a database and part of it launches an excel workbook.

Before closing my workbook I'd like to check if there are any other
workbooks open (that the user may be using). If there are no workbooks

open
I'd like to completely close Excel, otherwise just close my workbook.

The snag is, I won't know the file names of the other workbooks.

Is there any way you can check for open workbooks without knowing

there name?

Thanks






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
when i open an Excell file 3 workbooks open.Why? Iain40 Excel Discussion (Misc queries) 2 February 3rd 09 05:04 PM
When I open Excel, workbooks open automatically. How can I stop t Rhealbird Excel Discussion (Misc queries) 2 February 23rd 06 10:08 AM
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
Workbooks.Open closes other workbooks S. Daum Excel Programming 1 August 21st 03 07:47 PM
Workbooks.Open / .Open Text - How do you stop the .xls addition? Dave[_20_] Excel Programming 2 July 31st 03 04:03 AM


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