Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 'Save As' Macro Debug Error


--------------------------------------------------------------------------------

Hi Everybody,

Thank you for having me on this forum.

Thanks to the help of some Excel users, I was able to get some code to
save an existing worksheet to a new workbook. However, when a
duplication file name exists it prompts me to save as and if I click
'No' I get a debug error message. I'd still like the 'save as' message
to come up but is there a way I can get eliminate the debug error
message if 'No' is clicked? This is so it just works normally when
saving as a different file name or clicking no when an invoice is
accidentally duplicated.

Please see below code:




Code:
--------------------

With Sheets("Invoice2")
Dim invName As String
Sheets("Invoice2").Select
invName = Range("L4").Value & ".xls"
Sheets("Invoice2").Copy
ChDir "C:\Users\Justin\Documents\Razza Jam"
ActiveWorkbook.SaveAs Filename:=invName
ActiveWorkbook.Close
End With
--------------------


Any help would be greatly appreciated.

Kind regards,

Brown Teddy Bear


--
polar
------------------------------------------------------------------------
polar's Profile: http://www.thecodecage.com/forumz/member.php?userid=564
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=119605

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 'Save As' Macro Debug Error


polar;430581 Wrote:
--------------------------------------------------------------------------------

Hi Everybody,

Thank you for having me on this forum.

Thanks to the help of some Excel users, I was able to get some code to
save an existing worksheet to a new workbook. However, when a
duplication file name exists it prompts me to save as and if I click
'No' I get a debug error message. I'd still like the 'save as' message
to come up but is there a way I can get eliminate the debug error
message if 'No' is clicked? This is so it just works normally when
saving as a different file name or clicking no when an invoice is
accidentally duplicated.

Please see below code:




Code:
--------------------

With Sheets("Invoice2")
Dim invName As String
Sheets("Invoice2").Select
invName = Range("L4").Value & ".xls"
Sheets("Invoice2").Copy
ChDir "C:\Users\Justin\Documents\Razza Jam"
ActiveWorkbook.SaveAs Filename:=invName
ActiveWorkbook.Close
End With

--------------------


Any help would be greatly appreciated.

Kind regards,

Brown Teddy BearWhat is the error code that you get?



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=119605

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default 'Save As' Macro Debug Error

Try the following. If not what you want then feel free to get back to me.

With Sheets("Invoice2")
Dim invName As String
Sheets("Invoice2").Select
invName = Range("L4").Value & ".xls"
Sheets("Invoice2").Copy
ChDir "C:\Users\Justin\Documents\Razza Jam"

'Will ignore the error
On Error Resume Next
ActiveWorkbook.SaveAs Filename:=invName
On Error GoTo 0

'Will close without another alert message
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End With


--
Regards,

OssieMac


"polar" wrote:


--------------------------------------------------------------------------------

Hi Everybody,

Thank you for having me on this forum.

Thanks to the help of some Excel users, I was able to get some code to
save an existing worksheet to a new workbook. However, when a
duplication file name exists it prompts me to save as and if I click
'No' I get a debug error message. I'd still like the 'save as' message
to come up but is there a way I can get eliminate the debug error
message if 'No' is clicked? This is so it just works normally when
saving as a different file name or clicking no when an invoice is
accidentally duplicated.

Please see below code:




Code:
--------------------

With Sheets("Invoice2")
Dim invName As String
Sheets("Invoice2").Select
invName = Range("L4").Value & ".xls"
Sheets("Invoice2").Copy
ChDir "C:\Users\Justin\Documents\Razza Jam"
ActiveWorkbook.SaveAs Filename:=invName
ActiveWorkbook.Close
End With
--------------------


Any help would be greatly appreciated.

Kind regards,

Brown Teddy Bear


--
polar
------------------------------------------------------------------------
polar's Profile: http://www.thecodecage.com/forumz/member.php?userid=564
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=119605


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 'Save As' Macro Debug Error


Hi Simon and OssieMac,

Thank you for your responses.

The error message I was getting was:

"Application-time error 1004

Save as Object Failed"

This has now gone. The code you provided me with OssieMac works very
well.

Thank you again Simon and OssieMac for your help.

Kind regards,

Polar


--
polar
------------------------------------------------------------------------
polar's Profile: http://www.thecodecage.com/forumz/member.php?userid=564
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=119605

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 'Save As' Macro Debug Error


Glad we could be of help!
polar;430625 Wrote:
Hi Simon and OssieMac,

Thank you for your responses.

The error message I was getting was:

"Application-time error 1004

Save as Object Failed"

This has now gone. The code you provided me with OssieMac works very
well.

Thank you again Simon and OssieMac for your help.

Kind regards,

Polar



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=119605



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 'Save As' Macro Debug Error

If I just want to close a workbook, instead of using this

Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True

I use this
ActiveWorkbook.Close SaveChanges:=False

HTH,
Barb Reinhardt

"polar" wrote:


Hi Simon and OssieMac,

Thank you for your responses.

The error message I was getting was:

"Application-time error 1004

Save as Object Failed"

This has now gone. The code you provided me with OssieMac works very
well.

Thank you again Simon and OssieMac for your help.

Kind regards,

Polar


--
polar
------------------------------------------------------------------------
polar's Profile: http://www.thecodecage.com/forumz/member.php?userid=564
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=119605


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 'Save As' Macro Debug Error


Hi Barb,

Thank you for the tip. It's very helpful and much appreciated.

Kind regards,

Polar

Barb Reinhardt;430685 Wrote:
If I just want to close a workbook, instead of using this


Code:
--------------------

Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True

--------------------

I use this

Code:
--------------------
ActiveWorkbook.Close SaveChanges:=False

--------------------


HTH,
Barb Reinhardt

"polar" wrote:


Hi Simon and OssieMac,

Thank you for your responses.

The error message I was getting was:

"Application-time error 1004

Save as Object Failed"

This has now gone. The code you provided me with OssieMac works

very
well.

Thank you again Simon and OssieMac for your help.

Kind regards,

Polar


--
polar

------------------------------------------------------------------------
polar's Profile: 'The Code Cage Forums - View Profile: polar'

(http://www.thecodecage.com/forumz/member.php?userid=564)
View this thread: ''Save As' Macro Debug Error - The Code Cage

Forums' (http://www.thecodecage.com/forumz/sh...d.php?t=119605)




--
polar
------------------------------------------------------------------------
polar's Profile: http://www.thecodecage.com/forumz/member.php?userid=564
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=119605

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
Macro Debug Error Soroya1920 Excel Discussion (Misc queries) 1 June 26th 07 09:53 PM
When I try to save, it says debug, what does that mean? kali Excel Discussion (Misc queries) 1 January 10th 07 03:17 AM
How do I resolve debug error macro Excel 2000? At least, any lead Excel 2000 Macros debugger Excel Discussion (Misc queries) 5 October 25th 05 08:56 AM
when i save xls file, debug script is running and canno't save fil Imtiaz Excel Discussion (Misc queries) 1 July 16th 05 03:47 PM
down with the debug error hurlbut777 Excel Programming 1 January 8th 05 12:08 AM


All times are GMT +1. The time now is 08:13 AM.

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"