Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Messages msao Excel Worksheet Functions 4 November 17th 09 04:55 PM
Error Messages Kathy Excel Discussion (Misc queries) 9 May 16th 06 03:01 PM
Setting to stop error messages from showing? JENNYC Excel Discussion (Misc queries) 5 February 24th 06 10:05 PM
Statusbar messages stop updating [email protected] Excel Programming 4 November 30th 05 01:01 AM
Help with Error Messages Tha BeatMaker[_7_] Excel Programming 1 July 3rd 05 02:51 AM


All times are GMT +1. The time now is 01:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"