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

Why this code don't close excel? Code is assigned to button into userfor

Private Sub CommandButton4_Click(
ActiveWorkbook.Sav
If Workbooks.Count 1 The
ActiveWorkbook.Clos
Els
Application.Qui
End I
End Su

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Application.quit

You code would close the workbook with the code which causes the code to
terminate at that point.

Just do

for each bk in Application.Workbooks
bk.Save
Next
Application.Quit


"yuiriy" wrote in message
...
Why this code don't close excel? Code is assigned to button into userform

Private Sub CommandButton4_Click()
ActiveWorkbook.Save
If Workbooks.Count 1 Then
ActiveWorkbook.Close
Else
Application.Quit
End If
End Sub

TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Application.quit

Same result... In my primer I close book if there more books (there not .quit) , but when I us
application.quit not close this book... That I think that not a problem. Maybe userform


----- Tom Ogilvy wrote: ----

You code would close the workbook with the code which causes the code t
terminate at that point

Just d

for each bk in Application.Workbook
bk.Sav
Nex
Application.Qui


"yuiriy" wrote in messag
..
Why this code don't close excel? Code is assigned to button into userfor
Private Sub CommandButton4_Click(

ActiveWorkbook.Sav
If Workbooks.Count 1 The
ActiveWorkbook.Clos
Els
Application.Qui
End I
End Su
TI




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Application.quit

If excel can't close the workbook containing the code because the useform
prevents it, then you would need to unload the userform and run the code
from a general module, perhaps using Application.Ontime to start that
macro - to break the connection between the running code and the userform.

Public bCloseApp as Boolean

Public sub ShowForm
userform1.show
if bCloseApp then
for each bk in Application.Workbooks
bk.save
next
Application.Quit
End if
End Sub


in the userform

Private Sub CloseAppButton_Click()
bCloseApp = True
unload me
End Sub

--
Regards,
Tom Ogilvy


"yuriy" wrote in message
...
Same result... In my primer I close book if there more books (there not

..quit) , but when I use
application.quit not close this book... That I think that not a problem.

Maybe userform?


----- Tom Ogilvy wrote: -----

You code would close the workbook with the code which causes the code

to
terminate at that point.

Just do

for each bk in Application.Workbooks
bk.Save
Next
Application.Quit


"yuiriy" wrote in message
...
Why this code don't close excel? Code is assigned to button into

userform
Private Sub CommandButton4_Click()

ActiveWorkbook.Save
If Workbooks.Count 1 Then
ActiveWorkbook.Close
Else
Application.Quit
End If
End Sub
TIA






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Application.quit

No success:( Is this working for you? On my PC with Excel 2003 not:(
Pls... Somebody to post working on Excel2003 code... When user close
form if only one workbook to close excel or if there other books to
close only activeworkbook...
Sample (not working):( All varianst in prevision post not working too
for me:(

-----
'Close form
Private Sub CommandButton4_Click()
Application.OnTime Now + TimeValue("00:00:02"), "closew"
Unload Me
End Sub


=====

Sub closew()

ActiveWorkbook.Save
If Workbooks.Count 1 Then
ActiveWorkbook.Close
else
Application.Quit
endif

End Sub

------

Big thanks in advance
P.S. Is there variant mistake in my Excel config? But I wonder what
happens...



On Wed, 9 Jun 2004 10:37:26 -0400, "Tom Ogilvy"
wrote:

If excel can't close the workbook containing the code because the useform
prevents it, then you would need to unload the userform and run the code
from a general module, perhaps using Application.Ontime to start that
macro - to break the connection between the running code and the userform.

Public bCloseApp as Boolean

Public sub ShowForm
userform1.show
if bCloseApp then
for each bk in Application.Workbooks
bk.save
next
Application.Quit
End if
End Sub


in the userform

Private Sub CloseAppButton_Click()
bCloseApp = True
unload me
End Sub




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
Macro to quit application K11ngy Excel Discussion (Misc queries) 7 July 6th 07 04:48 PM
macro to close excel application other than application.quit mary Excel Programming 1 September 14th 04 03:43 PM
application.quit will not shut off application john Excel Programming 0 January 9th 04 11:29 PM
Open program with Application.Quit? Milos Setek Excel Programming 1 August 22nd 03 01:03 AM
Quit Application Robert Black Excel Programming 1 July 31st 03 04:15 PM


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