Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default 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
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
#DIV/O! Errror with Absolute Number Calculation Brent Excel Discussion (Misc queries) 7 May 11th 10 09:26 PM
Option Box protected errror Whois Clinton Excel Worksheet Functions 0 September 26th 08 04:34 PM
Data form errror lwm Excel Programming 3 February 4th 08 02:19 AM
Object defined errror N.F[_2_] Excel Discussion (Misc queries) 1 July 11th 07 10:14 PM
system errror &H8000FFFF Harikarishna New Users to Excel 1 July 8th 06 02:01 AM


All times are GMT +1. The time now is 08:26 PM.

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

About Us

"It's about Microsoft Excel"