Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run time error 1004, General ODBC error | New Users to Excel | |||
Runtime error '1004' General ODBC error | New Users to Excel | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
Error trapped only while stepping through the code - Not triggered when run | Excel Discussion (Misc queries) | |||
Error trapped only while stepping through the code - Not triggered when run | Excel Discussion (Misc queries) |