Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default quitting worksheet then excel if....

I have a program used to fill out forms in our department. When logging out
of the program (commandbutton) I can either close the workbook, or quit the
application.

What I would like to know: Is there a way to check to see if there are any
other workbooks open? If yes then close my program workbook. If no then
quit excel.

Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default quitting worksheet then excel if....

Try something like:

Sub bks()
Dim i As Integer
Dim wkb As Workbook
For Each wkb In Application.Workbooks
If wkb.Name < "PERSONAL.XLS" Then
i = i + 1
End If
Next wkb
If i 1 Then
ThisWorkbook.Close True
Else
ThisWorkbook.Save
Application.Quit
End If
End Sub

Hope this helps
Rowan

JNW wrote:
I have a program used to fill out forms in our department. When logging out
of the program (commandbutton) I can either close the workbook, or quit the
application.

What I would like to know: Is there a way to check to see if there are any
other workbooks open? If yes then close my program workbook. If no then
quit excel.

Thank you

  #3   Report Post  
Posted to microsoft.public.excel.programming
JNW JNW is offline
external usenet poster
 
Posts: 480
Default quitting worksheet then excel if....

Thank you for the reply!

Because it is one of those days... "Personal.xls" - is this the name of the
workbook I want to close?

Thanks again.



"Rowan Drummond" wrote:

Try something like:

Sub bks()
Dim i As Integer
Dim wkb As Workbook
For Each wkb In Application.Workbooks
If wkb.Name < "PERSONAL.XLS" Then
i = i + 1
End If
Next wkb
If i 1 Then
ThisWorkbook.Close True
Else
ThisWorkbook.Save
Application.Quit
End If
End Sub

Hope this helps
Rowan

JNW wrote:
I have a program used to fill out forms in our department. When logging out
of the program (commandbutton) I can either close the workbook, or quit the
application.

What I would like to know: Is there a way to check to see if there are any
other workbooks open? If yes then close my program workbook. If no then
quit excel.

Thank you


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default quitting worksheet then excel if....

No Personal.xls is a hidden workbook that holds the user's personal
macros. This book is opened automatically every time Excel starts so if
you want to check that only one visible workbook is open you should
exclude Personal.xls from your workbook count.

Hope this makes sense
Rowan

JNW wrote:
Thank you for the reply!

Because it is one of those days... "Personal.xls" - is this the name of the
workbook I want to close?

Thanks again.



"Rowan Drummond" wrote:


Try something like:

Sub bks()
Dim i As Integer
Dim wkb As Workbook
For Each wkb In Application.Workbooks
If wkb.Name < "PERSONAL.XLS" Then
i = i + 1
End If
Next wkb
If i 1 Then
ThisWorkbook.Close True
Else
ThisWorkbook.Save
Application.Quit
End If
End Sub

Hope this helps
Rowan

JNW wrote:

I have a program used to fill out forms in our department. When logging out
of the program (commandbutton) I can either close the workbook, or quit the
application.

What I would like to know: Is there a way to check to see if there are any
other workbooks open? If yes then close my program workbook. If no then
quit excel.

Thank you


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
Search function keeps quitting in Excel Rebecca[_2_] Excel Worksheet Functions 0 February 20th 07 12:41 AM
Error appearing after quitting from MS EXCEL 2003 SP1 Gianluigi Excel Discussion (Misc queries) 1 January 17th 05 02:37 AM
How to detect user quitting excel danzel Excel Programming 2 June 8th 04 12:18 PM
Problem quitting excel when it is used by ASP.NET application Tom Excel Programming 0 May 10th 04 08:35 PM
Quitting Excel without saving manishc[_2_] Excel Programming 1 November 16th 03 11:55 AM


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