Quting excel from within application

D

droopy928gt

I've got a very strange problem for which I can't find an explanation.

The application I made quits excel using application.quit. Befor
doing this I check if the workbook was saved and if not save it.


Code
-------------------
'Check if the workbook was saved
If Workbooks(ThisWorkbook.Name).Saved = False Then
'Save this workbook
Workbooks(ThisWorkbook.Name).Save
End If

'Close excel
Application.Qui
-------------------


Using above code I would think that the application would quit withou
asking for it to be saved. Well, it doesn't. Only when I add th
application.displayalerts = false statement will it do so. Afterward
when checking I can't find any differences between a saved and no
saved workbook though. Apart from that, when quiting the applicatio
there's only 1 workbook open.

It becomes weirder when you know that this problem only occurs afte
having done something using the application. The application itself i
basically a database which displays data in textboxes depending upo
certain criteria. It has 2 worksheets being 1 for the data used itsel
and 1 which contains temp data used in the application. Both sheet
though are saved when using the workbooks().save statement.

Could any of you offer an explanation of this strange behavior or migh
have experienced similar before? Is this maybe some sort of bug lik
the usedrange problem?

I use the workaround of setting displayalerts to off now but I woul
really like to know why this happens.

Thanks and best regards,

Leo
 
D

droopy928gt

Hi Tom,

Thanks for the reply.

I'm not at work at the moment but am surely gonna try this tomorrow.
The application though I've made was started and written using
excel2003. Only a couple of months ago did I once open and work on it
in excel2000 but since then I've also upgraded my homecomputers to
excel2003. Let you know though as this one really had me puzzled.

As for the usedrange bug, maybe I referred to it wrongly but what I
meant was for workbooks to become bloated over time without any
significant reason. This occurred to me also and ended up with a
workbook of 7.5MB. Searching this forum I found a simple routine with
which I could reduce it to 700KB. Apparently excel didn't release
empty cells properly for which the only solution was to delete empty
rows and then saving the sheet again.

Thanks again and best regards,

Leon
 
G

Guest

I understand what you are saying about the usedrange, but I would have to
categorize that as your own "misconduct" <g>.

There are other things beside a value being stored in a cell that will cause
excel to store information about that cell and appear "bloated" as you say.
 
D

droopy928gt

Hi Tom,

You're so right about the other things causing cells to not be emptied
The problem, at least for me, was always that I never set or use thos
things like fontsize, type, borders, etc. The only thing I did was t
enter a number or text in cells. Apart from that, if you use a comman
like .clearcontent you would expect a cell to be empty / unused but i
isn't.

Nowadays I use, also for this, a workaround to the actual problem b
using .specialcells(xlconstants) to select and clear in combinatio
with the code courtesy of DJR during quiting to delete empty rows.

This does help but debatably should not have to be used.

Haven't tried your initial suggestion yet but will post when I do.

Best regards,

Leo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top