![]() |
Is it possible to turn off errors in macros???
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. -- sungen99 ------------------------------------------------------------------------ sungen99's Profile: http://www.excelforum.com/member.php...fo&userid=9144 View this thread: http://www.excelforum.com/showthread...hreadid=505730 |
Is it possible to turn off errors in macros???
On Error Resume Next
Insert this line at the beginning of your code. "sungen99" wrote: 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. -- sungen99 ------------------------------------------------------------------------ sungen99's Profile: http://www.excelforum.com/member.php...fo&userid=9144 View this thread: http://www.excelforum.com/showthread...hreadid=505730 |
Is it possible to turn off errors in macros???
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 -- Hmm...they have the Internet on COMPUTERS now! "sungen99" wrote: 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. -- sungen99 ------------------------------------------------------------------------ sungen99's Profile: http://www.excelforum.com/member.php...fo&userid=9144 View this thread: http://www.excelforum.com/showthread...hreadid=505730 |
Is it possible to turn off errors in macros???
what is the purpose of the bottom 4 lines?
"MDW" wrote: 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 -- Hmm...they have the Internet on COMPUTERS now! "sungen99" wrote: 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. -- sungen99 ------------------------------------------------------------------------ sungen99's Profile: http://www.excelforum.com/member.php...fo&userid=9144 View this thread: http://www.excelforum.com/showthread...hreadid=505730 |
Is it possible to turn off errors in macros???
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. -- Hmm...they have the Internet on COMPUTERS now! "Sloth" wrote: what is the purpose of the bottom 4 lines? "MDW" wrote: 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 -- Hmm...they have the Internet on COMPUTERS now! "sungen99" wrote: 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. -- sungen99 ------------------------------------------------------------------------ sungen99's Profile: http://www.excelforum.com/member.php...fo&userid=9144 View this thread: http://www.excelforum.com/showthread...hreadid=505730 |
All times are GMT +1. The time now is 03:57 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com