Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with debug errror and saving only one worksheet
I am hoping someone can help me here, I have this syntax that works great
except for 2 things, I just want to save the worksheet named proposal and if the user does not wish to over write the existing file and they click no for the process to stop and not give a debug error. here is what I have Private Sub CommandButton1_Click() ' ' prepprop03 Macro ' Macro recorded 6/2/2009 by Neall ' ' Rows("3:4").Select Selection.EntireRow.Hidden = True Range("C16:C17").Select Selection.Interior.ColorIndex = 2 Dim originalPrinter If MsgBox("Did you need to change the Industry?" & vbCrLf & vbCrLf & _ "Click No to continue to Step 2", vbYesNo) < vbNo Then Exit Sub If MsgBox("Did you need to change the Pricing Level?" & vbCrLf & vbCrLf & _ "Click No to continue with Step 3", vbYesNo) < vbNo Then Exit Sub If MsgBox("Are there any further changes you wish to make?" & vbCrLf & vbCrLf & _ "Click No to continue saving quote to C:\TEMP", vbYesNo) < vbNo Then Exit Sub Dim CSName As String Dim OldPath As String Dim OldFName As String 'This is the cell containing the name for the new book. CSName = Worksheets("NEW_RENEWAL_CALC").Range("B3").Value folder = Environ("Temp") 'This is the code to get path & Name data, not used. 'OldPath = ActiveWorkbook.Path 'MsgBox OldPath 'OldFName = ActiveWorkbook.Name 'MsgBox OldFName 'ActiveWorkbook.Sheets.Select 'Make a copy of the original workbook. Sheets.Copy ActiveSheet.Activate 'Save the new workbook. ActiveWorkbook.SaveAs (CSName) 'Close the new saved workbook. ActiveWorkbook.Close 'Close the original workbook, do not save. 'ActiveWorkbook.Close (False) End Sub Any help would be greatly appreciated -- Neall -- Neall |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
help with debug errror and saving only one worksheet
Don't confuse WORKBOOK with WORKSHEET. A workbook is an excel file
containing one or more worksheets (normally). if you save the active workbook with a new name, you will still have only the one workbook open change these three blocks 'Save the new workbook. ActiveWorkbook.SaveAs (CSName) 'Close the new saved workbook. ActiveWorkbook.Close 'Close the original workbook, do not save. 'ActiveWorkbook.Close (False) to 'Save the new workbook. ActiveWorkbook.SaveAs (CSName) 'Close the workbook. ActiveWorkbook.Close FALSE "Neall" wrote in message ... I am hoping someone can help me here, I have this syntax that works great except for 2 things, I just want to save the worksheet named proposal and if the user does not wish to over write the existing file and they click no for the process to stop and not give a debug error. here is what I have Private Sub CommandButton1_Click() ' ' prepprop03 Macro ' Macro recorded 6/2/2009 by Neall ' ' Rows("3:4").Select Selection.EntireRow.Hidden = True Range("C16:C17").Select Selection.Interior.ColorIndex = 2 Dim originalPrinter If MsgBox("Did you need to change the Industry?" & vbCrLf & vbCrLf & _ "Click No to continue to Step 2", vbYesNo) < vbNo Then Exit Sub If MsgBox("Did you need to change the Pricing Level?" & vbCrLf & vbCrLf & _ "Click No to continue with Step 3", vbYesNo) < vbNo Then Exit Sub If MsgBox("Are there any further changes you wish to make?" & vbCrLf & vbCrLf & _ "Click No to continue saving quote to C:\TEMP", vbYesNo) < vbNo Then Exit Sub Dim CSName As String Dim OldPath As String Dim OldFName As String 'This is the cell containing the name for the new book. CSName = Worksheets("NEW_RENEWAL_CALC").Range("B3").Value folder = Environ("Temp") 'This is the code to get path & Name data, not used. 'OldPath = ActiveWorkbook.Path 'MsgBox OldPath 'OldFName = ActiveWorkbook.Name 'MsgBox OldFName 'ActiveWorkbook.Sheets.Select 'Make a copy of the original workbook. Sheets.Copy ActiveSheet.Activate 'Save the new workbook. ActiveWorkbook.SaveAs (CSName) 'Close the new saved workbook. ActiveWorkbook.Close 'Close the original workbook, do not save. 'ActiveWorkbook.Close (False) End Sub Any help would be greatly appreciated -- Neall -- Neall |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
#DIV/O! Errror with Absolute Number Calculation | Excel Discussion (Misc queries) | |||
Option Box protected errror | Excel Worksheet Functions | |||
Data form errror | Excel Programming | |||
Object defined errror | Excel Discussion (Misc queries) | |||
system errror &H8000FFFF | New Users to Excel |