ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Application.Quit (https://www.excelbanter.com/excel-programming/379324-application-quit.html)

elcroco

Application.Quit
 
I would like to use this function in one of my application.So I wrote
the following code:

Sub sTestAppQuite()

Application.Display
Application.Quit

End Sub

When I m testing it, the "Save" dialog box opens, asking me whether or
not I want to save the workbook. As I would like to avoid this
behaviour, what I hhave to do ???

Thanks

G


Roger Govier

Application.Quit
 
Hi

Application.DisplayAlerts = False

--
Regards

Roger Govier


"elcroco" wrote in message
ups.com...
I would like to use this function in one of my application.So I wrote
the following code:

Sub sTestAppQuite()

Application.Display
Application.Quit

End Sub

When I m testing it, the "Save" dialog box opens, asking me whether or
not I want to save the workbook. As I would like to avoid this
behaviour, what I hhave to do ???

Thanks

G




elcroco

Application.Quit
 
Hi,

I forgot in my first message the Application.DisplayAlerts = False I
have set in my procedure
It doesn't work because the "Save" dialog box is not an alert

G


Roger Govier a écrit :

Hi

Application.DisplayAlerts = False

--
Regards

Roger Govier


"elcroco" wrote in message
ups.com...
I would like to use this function in one of my application.So I wrote
the following code:

Sub sTestAppQuite()

Application.Display
Application.Quit

End Sub

When I m testing it, the "Save" dialog box opens, asking me whether or
not I want to save the workbook. As I would like to avoid this
behaviour, what I hhave to do ???

Thanks

G



Bob Phillips

Application.Quit
 
Maybe try

Activeworkbook.Close Savechanges:=False

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"elcroco" wrote in message
ups.com...
Hi,

I forgot in my first message the Application.DisplayAlerts = False I
have set in my procedure
It doesn't work because the "Save" dialog box is not an alert

G


Roger Govier a écrit :

Hi

Application.DisplayAlerts = False

--
Regards

Roger Govier


"elcroco" wrote in message
ups.com...
I would like to use this function in one of my application.So I wrote
the following code:

Sub sTestAppQuite()

Application.Display
Application.Quit

End Sub

When I m testing it, the "Save" dialog box opens, asking me whether or
not I want to save the workbook. As I would like to avoid this
behaviour, what I hhave to do ???

Thanks

G




Nik[_3_]

Application.Quit
 
elcroco wrote:
I would like to use this function in one of my application.So I wrote
the following code:

Sub sTestAppQuite()

Application.Display
Application.Quit

End Sub

When I m testing it, the "Save" dialog box opens, asking me whether or
not I want to save the workbook. As I would like to avoid this
behaviour, what I hhave to do ???

Areyou sure that the user won't have another file open and lose work in
that?

You could set thisworkbook.saved = true, which will tell Excel that
there are no chanegs to save. If there is only one workbook open, Excel
will quit; if there is another workbook the user will be prompted to
save changes if there are any.

Nik

elcroco

Application.Quit
 
Bob, I m not sure that your proposal answers properly to my question,
because this line of code close the workbook but not excel


Bob Phillips a écrit :

Maybe try

Activeworkbook.Close Savechanges:=False

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"elcroco" wrote in message
ups.com...
Hi,

I forgot in my first message the Application.DisplayAlerts = False I
have set in my procedure
It doesn't work because the "Save" dialog box is not an alert

G


Roger Govier a écrit :

Hi

Application.DisplayAlerts = False

--
Regards

Roger Govier


"elcroco" wrote in message
ups.com...
I would like to use this function in one of my application.So I wrote
the following code:

Sub sTestAppQuite()

Application.Display
Application.Quit

End Sub

When I m testing it, the "Save" dialog box opens, asking me whether or
not I want to save the workbook. As I would like to avoid this
behaviour, what I hhave to do ???

Thanks

G



elcroco

Application.Quit
 
Nik,

I consider that there's only one workbook I believe that maybe one the
addins I have is the cause of my problems



Nik a écrit :

elcroco wrote:
I would like to use this function in one of my application.So I wrote
the following code:

Sub sTestAppQuite()

Application.Display
Application.Quit

End Sub

When I m testing it, the "Save" dialog box opens, asking me whether or
not I want to save the workbook. As I would like to avoid this
behaviour, what I hhave to do ???

Areyou sure that the user won't have another file open and lose work in
that?

You could set thisworkbook.saved = true, which will tell Excel that
there are no chanegs to save. If there is only one workbook open, Excel
will quit; if there is another workbook the user will be prompted to
save changes if there are any.

Nik



elcroco

Application.Quit
 
I would like to bring a new information:

I did some changes into my code. Now, I call in sTestAppQuite,
ActiveWorkbook.Close (False) and in ThisWorkbook I put Application.Quit
into Workbook_BeforeClose(cancel as boolean).
So, now, if I have only one workbook opened, then it works properly,
but if I have several, I did some little changes in sTestAppQuite as
follow:

Sub sTestAppQuite()

dim wbk as Workbook

for each wbk in Application.Workbooks

if wbk.name < "WorkBook_SpecificName" then
wbk.close(false)
end if
' I close workbooks different from the one in which I call
Application.Quit in Wotrkbook_BeforeClose

next wbk

set wbk = ActiveWorkBook
wbk.close(false) <----- Now we go into Workbook_BeforeClose and
call Application.Quit

end sub

When I m testing this new version, all the workbooks are closed, but
not excel !!!!

Any ideas ?

Thks

G

elcroco a écrit :

I would like to use this function in one of my application.So I wrote
the following code:

Sub sTestAppQuite()

Application.Display
Application.Quit

End Sub

When I m testing it, the "Save" dialog box opens, asking me whether or
not I want to save the workbook. As I would like to avoid this
behaviour, what I hhave to do ???

Thanks

G



Bob Phillips

Application.Quit
 
I meant add it before the code that you have, not just on its own.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"elcroco" wrote in message
ups.com...
Bob, I m not sure that your proposal answers properly to my question,
because this line of code close the workbook but not excel


Bob Phillips a écrit :

Maybe try

Activeworkbook.Close Savechanges:=False

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"elcroco" wrote in message
ups.com...
Hi,

I forgot in my first message the Application.DisplayAlerts = False I
have set in my procedure
It doesn't work because the "Save" dialog box is not an alert

G


Roger Govier a écrit :

Hi

Application.DisplayAlerts = False

--
Regards

Roger Govier


"elcroco" wrote in message
ups.com...
I would like to use this function in one of my application.So I wrote
the following code:

Sub sTestAppQuite()

Application.Display
Application.Quit

End Sub

When I m testing it, the "Save" dialog box opens, asking me whether or
not I want to save the workbook. As I would like to avoid this
behaviour, what I hhave to do ???

Thanks

G





All times are GMT +1. The time now is 02:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com