Automatisch beantwoorden vragen

W

wietse.uitenbroek

Hallo,

Ik vroeg me af of het mogelijk is om automatische msgboxen in Excel
zoals: Do you want to save the changes...
en dergelijke automatisch te laten beantwoorden.
Dus wil automatisch "ja" of "nee" antwoorden.

Is het mogelijk en zo ja hoe dien ik dit te doen?

Alvast bedankt!
 
W

wietse.uitenbroek

Hi there,

I was wondering if it is possible to automatically answer to msgboxes
like "Do you want to save the changes..."
So i want to answer this question in the VBA code. Is it possible and
if so how?

Thanks!
 
G

Guest

If your question is:
Prevent or stop the Save Dialog box then put this in ThisWorkbook code:

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


If your question is how to automatically save without the Dialog box then
put this in ThisWorkbook code:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWorkbook.Save
End Sub
 
G

Guest

Much better.

If the user attempts to close the file or exit Excel, The
Workbook_BeforeClose will be activated BEFORE the normal dialog box appears.
You can then insert your own logic:

1. if you want to save, just:
ActiveWorkbook.Save
Exit Sub


2. if you don't want to save:
ActiveWorkbook.Saved=True
Exit Sub

In the second case you are tricking Excel into thinking that workbook has
been saved and thus Excel won't botherr to bring up the dialog box.
 
W

wietse.uitenbroek

Thanks for the quick answer, the problem is that the msgbox Do you
want to save the changes is answered by the code but after that one on
other msgbox appears that says that "There is a large amount of
information on the Clipboard......To save...click Yes"
This question should also be answered automatiacally with Yes can you
help me with that?
 
G

Guest

try:
Application.DisplayAlerts = False
before the Exit

I don't know if it will work because I can't test it.
 
D

Dave Peterson

application.cutcopymode = false


Thanks for the quick answer, the problem is that the msgbox Do you
want to save the changes is answered by the code but after that one on
other msgbox appears that says that "There is a large amount of
information on the Clipboard......To save...click Yes"
This question should also be answered automatiacally with Yes can you
help me with that?
 

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