Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can error 1004 be trapped????


I am still having a problem with trapping error 1004. Again I have cod
saving the spreadsheet as SaveAs, but when I select no of cancel, I ge
the end debug error 1004.

I have posted this several days ago with code and pulling hair out.

Los

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can error 1004 be trapped????


Hi Richard,

You can trap error with "On Error" method.
Please look into "On error resume next" in your VBE help.


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Can error 1004 be trapped????

Richard,

Try this modification to your code (below).

HTH,
Shockley



Sub Macro3()

Dim ans As String
Dim ans2 As String
Dim number

ans = "C:\" & Range("playsave").Value
ans2 = Range("playsave").Value & ".xls"

'There are better ways of checking whether a directory
exists!
On Error Resume Next
MkDir ans
On Error GoTo 0

ChDir ans

'Tests for existence of file in current directory:
sTest = Dir(ans & "\" & ans2)

'Saves the file if it doesn't already exist:
If sTest = "" Then
ActiveWorkbook.SaveAs FileName:=ans & "\" & ans2

'Replaces the file only if "yes" is selected from the
message box:
Else
bTest = MsgBox("A file named " & sTest & " already exists in this
location. " & _
"Do you wish to replace it?", 4)
If bTest = 6 Then
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=ans & "\" & ans2
Application.DisplayAlerts = True
End If
End If
End Sub




"Richard m" wrote in message
...

I am still having a problem with trapping error 1004. Again I have code
saving the spreadsheet as SaveAs, but when I select no of cancel, I get
the end debug error 1004.

I have posted this several days ago with code and pulling hair out.

Lost


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can error 1004 be trapped????


Hello shockley,

I will be trying this code a little bit latter in the day. A couple o
questions pops up after reading the code.

on error resume next -- Don't really understand how this works but
will I will be reading up on this and on error goto 0.

Found out after the post that the path I am looking for is c:\folder1
and then I will write to c:\folder1\playsave\*.xls. I will have t
create the playsave folder if it does not exist. If it is not on
drive then the path is d:\folder1.

Thanks for the help in code. I sure enjoy this forum.

Richard

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

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
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
Runtime error '1004' General ODBC error star_lucas New Users to Excel 0 August 29th 05 04:09 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 7 March 7th 05 06:29 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 0 February 28th 05 06:26 PM


All times are GMT +1. The time now is 01:00 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"