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.

Recommended Answers

All 3 Replies

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

Good one :) thanks a lot mate. It has been solved :)

It's a pleasure. Happy coding.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.