Macro help

M

Manju

Dear All
I have a macro which opens a temporary excel file modifies some data
copies and pastes into another file from where i call this macro and
closes the temporary file. At this point it stops and pops up a window
do you want to save this file since i have modified this file this
being a temporary file which I overwrite every time i dont need to
save but unless i press Yes or No the macro won't move further. How do
we avoid this? I know the answer may be simple But i create macros by
recording tool and not by directly writing in VB editor.

My main intention is to close the file without saving but shouldnot
wait for user input to do so.

Please Help
Manju
 
G

Guest

Just make Excel THINK the file has been already saved:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ThisWorkbook.Saved = True
End Sub

This goes in ThisWorkbook code
 
C

CLR

Application.DisplayAlerts = False 'shuts off the pop-ups
Put your SAVE code here...............
Application.DisplayAlerts = True 'turns things back to normal
Application.Quit

hth
Vaya con Dios,
Chuck, CABGx3
 
G

Gord Dibben

Manju

With Activeworkbook 'assuming this is the temporary file
.Saved = True 'does not save changes
.Close
End with


Gord Dibben MS Excel MVP
 
M

Manju

Thanks!
This worked.

Manju

With Activeworkbook 'assuming this is the temporary file
.Saved = True 'does not save changes
.Close
End with

Gord Dibben MS Excel MVP





- Show quoted text -
 

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