Having a macro interact with a dialog box.

  • Thread starter Thread starter Louis
  • Start date Start date
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
 
Louis,

Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete

HTH
Anders Silvén
 
Back
Top