Error handling clarification

corquando

Board Regular
Joined
Jan 8, 2009
Messages
82
Hello, gurus.

A quick question having to do with semantics as much as anything else.

I have a routine that occasionally and inexplicably throws a "File not found" error when performing a mail merge. When this occurs, the debug button opens the VBA studio and I hit 'F5' and it takes off again as if the error never happened. It's not on the same template every time, nor is the pattern anything but random, and the files in question do exist because their names are retrieved from existing folders earlier in the program.

Anyway, I'd like to bracket the offending command in "On Error Resume Next" and "On Error GoTo 0" so that in my absence my staff can run the program and not have to contend with this randomness. However, everything I read says that "On Error Resume Next" "ignores the error and resumes execution on the next line of code."

I'd like execution to resume on the offending command itself, since there never seems to be an actual error when handled manually. Am I simply reading the explanation incorrectly, or should I approach the situation differently?

Thanks.

Just in case, the command in question is displayed below. All standard Dims and Sets are present.

Code:
            AppWd.ActiveDocument.MailMerge.OpenDataSource Name:= _
                "G:\Huge\Big\Medium\Specific\DocMaker.xlsm" _
                , ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
                AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _
                WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
                Format:=wdOpenFormatAuto, Connection:= _
                "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=G:\Huge\Big\Medium\Specific\DocMaker.xlsm;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Je" _
                , SQLStatement:="SELECT * FROM `DataSet$`", SQLStatement1:="", SubType:= _
                wdMergeSubTypeAccess
 
LOL :)

I was in an infinte loop of despair once, back in college when Debbie whatever-her-name-was broke up with me. Nontheless, I'll see if that alleviates the issue, and it could be more flexible than the wait variation.

I have about 35 programs I run, so I'll start applying these tools where they seem likely to help, and my infinte loop of despair propensity should be diminished.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,224,520
Messages
6,179,270
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top