Is it possible to turn off errors in macros???

S

sungen99

Is it possible to turn off errors in macros???

I want to save a file to a thumb drive but depending on where you are,
Office or Home the drive location will be different. Office is x: and
Home is f:

I think the best way to accomplish what I need to do is to save the
file on both locations. When the macro runs it is going to error out on
one of the attempts to save but if I can some how turn off that function
it will automatically save. This way there is no need to ask the user if
he is at home or at work.

Again, my programming ability is limited to hacking existing code and
my searching the forums has not turned up anything like this.

Thanks again for your help with this. It is much appreciated.
 
G

Guest

This will work, but it will quash ALL errors ("Not enough space to save",
"Your computer is on fire", etc.), so use it with extreme caution.

On Error Resume Next

' You save code goes here

If Err.Number <> 0 Then
Err.Clear
End If

On Error GoTo 0
 
G

Guest

what is the purpose of the bottom 4 lines?

MDW said:
This will work, but it will quash ALL errors ("Not enough space to save",
"Your computer is on fire", etc.), so use it with extreme caution.

On Error Resume Next

' You save code goes here

If Err.Number <> 0 Then
Err.Clear
End If

On Error GoTo 0
 
G

Guest

On Error GoTo 0 gives VBA back its error handling. Clearing the errors object
ensures that if there WAS an error generated by saving, it isn't flagged once
VBA is back in control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top