help with debug errror and saving only one worksheet

N

Neall

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
 
P

Patrick Molloy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top