![]() |
How to stop error messages from showing
I have a spreadsheet that when opened for the first time opens to a sheet
named start and all other sheets are hidden. You click on a button that says start and it runs this script: Private Sub cmdactivation_Click() '1)unhide sheets, 2)create datasheet, 3)delete sheet3, delete sheet2, select sheet1, 4)rename, save & close 5)delete start sheet Sheets("CONTROL PANEL").Visible = True Workbooks.Add ActiveWorkbook.SaveAs FileName:= _ "C:\windows\datasheet2006.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet2").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet1").Select Sheets("Sheet1").Name = "datasheet" ActiveWorkbook.Save ActiveWindow.Close Sheets("START").Select On Error Resume Next Application.DisplayAlerts = False ActiveWindow.SelectedSheets.Delete Application.DisplayAlerts = True End Sub If the datasheet2006.xls it creates already exists I get an error saying it already exists do I want to replace it. Is there a way to stop the windows error message from coming up and just replace it by default? Thanks, Phil |
How to stop error messages from showing
application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:= _ "C:\windows\datasheet2006.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False Application.DisplayAlerts = true or On Error Resume Next Kill "C:\windows\datasheet2006.xls" On Error goto 0 ActiveWorkbook.SaveAs FileName:= _ "C:\windows\datasheet2006.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False -- Regards, Tom Ogilvy "phil-rge-ee" wrote: I have a spreadsheet that when opened for the first time opens to a sheet named start and all other sheets are hidden. You click on a button that says start and it runs this script: Private Sub cmdactivation_Click() '1)unhide sheets, 2)create datasheet, 3)delete sheet3, delete sheet2, select sheet1, 4)rename, save & close 5)delete start sheet Sheets("CONTROL PANEL").Visible = True Workbooks.Add ActiveWorkbook.SaveAs FileName:= _ "C:\windows\datasheet2006.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet2").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet1").Select Sheets("Sheet1").Name = "datasheet" ActiveWorkbook.Save ActiveWindow.Close Sheets("START").Select On Error Resume Next Application.DisplayAlerts = False ActiveWindow.SelectedSheets.Delete Application.DisplayAlerts = True End Sub If the datasheet2006.xls it creates already exists I get an error saying it already exists do I want to replace it. Is there a way to stop the windows error message from coming up and just replace it by default? Thanks, Phil |
How to stop error messages from showing
Beautiful........ thanks Tom. I went with the first suggestion. I actually
had the right idea using the application.displayalerts but I was putting it around the workbook.add instead of the activeworkbook.saveas filename:=_ So I was putting it in the wrong place. Thanks for the help, worked great. Phil "Tom Ogilvy" wrote: application.DisplayAlerts = False ActiveWorkbook.SaveAs FileName:= _ "C:\windows\datasheet2006.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False Application.DisplayAlerts = true or On Error Resume Next Kill "C:\windows\datasheet2006.xls" On Error goto 0 ActiveWorkbook.SaveAs FileName:= _ "C:\windows\datasheet2006.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False -- Regards, Tom Ogilvy "phil-rge-ee" wrote: I have a spreadsheet that when opened for the first time opens to a sheet named start and all other sheets are hidden. You click on a button that says start and it runs this script: Private Sub cmdactivation_Click() '1)unhide sheets, 2)create datasheet, 3)delete sheet3, delete sheet2, select sheet1, 4)rename, save & close 5)delete start sheet Sheets("CONTROL PANEL").Visible = True Workbooks.Add ActiveWorkbook.SaveAs FileName:= _ "C:\windows\datasheet2006.xls", _ FileFormat:=xlNormal, Password:="", WriteResPassword:="", _ ReadOnlyRecommended:=False, CreateBackup:=False Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet2").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet1").Select Sheets("Sheet1").Name = "datasheet" ActiveWorkbook.Save ActiveWindow.Close Sheets("START").Select On Error Resume Next Application.DisplayAlerts = False ActiveWindow.SelectedSheets.Delete Application.DisplayAlerts = True End Sub If the datasheet2006.xls it creates already exists I get an error saying it already exists do I want to replace it. Is there a way to stop the windows error message from coming up and just replace it by default? Thanks, Phil |
All times are GMT +1. The time now is 01:31 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com