Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error number of saving in a server

Status
Not open for further replies.

cesarsoto

Technical User
Oct 3, 2002
3
US
Hello everyone, I did a Macro for Excel 2000 that execute a Save as action to a server, sometimes the server is down or had some problems ,when a run the Save As macro the macro breaks, I 've tried with "On error" function using the Error Number = 1004 to ask to the user's another path, But I'd been watching that doesn't work .

Example:

Public Function case()
Dim msg, Style, Title, Help, Ctxt, Response, MyString, Default, MyValue

On Error GoTo ErrorHandler

ActiveWorkbook.SaveAs Filename:="\\server\folder\file.PRN", FileFormat:= _xlTextPrinter, CreateBackup:=False

ErrorHandler:
Select Case Err.Number
Case 1004
msg = "Do you want to save in another path?"
Style = vbYesNo + vbDefaultButton2
Title = "Information"
Help = "DEMO.HLP"
Ctxt = 1000
Response = MsgBox(msg, Style, Title, Help, Ctxt)
If Response = vbYes Then

msg = "Enter your path"
Title = "Path"
Default = "c:"
MyValue = InputBox(msg, Title,Default)
ActiveWorkbook.SaveAs Filename:=MyValue & "\file.PRN", FileFormat:= _xlTextPrinter, CreateBackup:=False

Does anybody knows the Error Number or the correct action for this Problem??

Thanks

Cesar Soto

 
cesarsoto,

Why not test for the existinance of the folder or a file in that directory before attempting the save as? If it exists, you should be able to connect to it, assuming you have permissions.

One way you could do this, is by using WMI. See following links for help.

Testing IP Connectivity With WMI

Also, checkout SCRIPTOMATIC for samples:

TechNet Home > Script Center > Files and Folders > Verify that a File Exists (Check the Left Menu)

Hope this helps.
DougCranston
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top