Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Error Messages | Excel Worksheet Functions | |||
Error Messages | Excel Discussion (Misc queries) | |||
Setting to stop error messages from showing? | Excel Discussion (Misc queries) | |||
Statusbar messages stop updating | Excel Programming | |||
Help with Error Messages | Excel Programming |