Hi All,

I have a sub and trap the error with:
------------------------------------------

private sub mySub(mydoc as string)
On error goto goto handlemyerror

kill app.path & "\" & mydoc

handlemyerror:
msgbox "I cannot kill it"
end sub

------------------------------------------

mydoc is word document with 2-3 pages length.

It works fine to avoid the run-time error if the mydoc is currently opened...

But, the annoying thing is, the error still exist although mydoc is no longer opened :(

When I erase handlemyerror section and modified the sub into:

------------------------------------------

private sub mySub(mydoc as string)

kill app.path & "\" & mydoc

end sub

------------------------------------------

then I can kill mydoc without any runtime error... (when it is no longer opened).


My question is... the error trap is still "finding fault" while there is no run time error? If there is other error, I only interested on trap "run time error", I don't care about any other error, how can I ignore them?

thanks.

You have your error trap coding incorrect -

Try the following...

private sub mySub(mydoc as string)
On error GoTo handlemyerror 'only one goto call allowed

kill app.path & "\" & mydoc

'You hgave to exit sub to goto err handler
Exit Sub

handlemyerror:

msgbox "I cannot kill it"
end sub
This question has already been answered. Start a new discussion instead.