View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff[_5_] Harald Staff[_5_] is offline
external usenet poster
 
Posts: 47
Default To say "no" with vba

Hi Pet

You should close the workbook, not the window, or it will err if it has more than one windows. What you want is
"Application.DisplayAlerts". Also, setting Saved to true would avoid the message. Try this, it uses both techniques and should be
100% foolproof:

Sub CloseIt()
On Error Resume Next
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Workbooks("Data.xls").Saved = True
Workbooks("Data.xls").Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

--
HTH. Best wishes Harald
Excel MVP

Followup to newsgroup only please.

"Peter" skrev i melding ...
Hi,
I have a macro
...Windows("Data.xls").Activate
ActiveWindow.Close
Application.ScreenUpdating = True

....

that closes the workbook and it ask me everytime "Do you
want to save the changes you made?" and i must click it NO
Is it possibile not having this question automatize the
answer "NO". Regards
Pet