Having a macro interact with a dialog box.

L

Louis

I have a macro that creates a worksheet in a workbook.
Imports data in it formats it, prints it, and then the
macro deletes the worksheet.

When I run the macro evrything is done perfectly except
that I have to interact when a dialog box confirming the
deletion of the worksheet pops up.

Is there some code that would let the macro answer "OK" to
the dialog box so that it could run unattended?

My code is as follows:

ActiveWindow.SelectedSheets.PrintOut Copies:=1
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
'Dialog box appears here
Range("A6").Select
End Sub

Thanks in advance
 
A

Anders S

Louis,

Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete

HTH
Anders Silvén
 

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