trapping run-time error 4198

C

ctyrrell

I am experiencing a run-time error 4198 when comparing certain Word
documents using vba (from Access 2000 - automating Word 2000). In
general, I think it is caused when trying to compare documents that
have already been compared. My problem is that I cannot trap the error.
I have an On Error goto statement right before the doc.Compare filename
statement, but it does not go to the error handler when the error
occurs, instead presenting the 'Command failed' message to the User and
then showing the yellow highlight on the Compare command when the
'Debug' button is clicked. I have tried setting the DisplayAlerts to
each of the 3 different choices right before the Compare, all to no
avail. Behaviour remains the same. The same code works fine for many
other documents, but I want to gracefully be able to handle this
problem, even if it is only to log the error and move on to the next
file to be processed.

Any ideas on why I can't trap this error? Anything different I can do?
Any way I can detect if the file has already been compared, and thus
avoid comparing when it would cause this error?

Any help much appreciated, Thanks
Christine
 
C

Cindy M -WordMVP-

I am experiencing a run-time error 4198 when comparing certain Word
documents using vba (from Access 2000 - automating Word 2000). In
general, I think it is caused when trying to compare documents that
have already been compared. My problem is that I cannot trap the error.
I have an On Error goto statement right before the doc.Compare filename
statement, but it does not go to the error handler when the error
occurs, instead presenting the 'Command failed' message to the User and
then showing the yellow highlight on the Compare command when the
'Debug' button is clicked. I have tried setting the DisplayAlerts to
each of the 3 different choices right before the Compare, all to no
avail. Behaviour remains the same. The same code works fine for many
other documents, but I want to gracefully be able to handle this
problem, even if it is only to log the error and move on to the next
file to be processed.
Assuming the problem is that a document has already been compared, then
it probably contains changes that haven't yet been accepted/rejected? If
you test doc.Revisions.Count is it greater than 0 in such cases? Could
you use this test to avoid the problem?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
C

ctyrrell

Cindy,
Thanks for taking the time to respond. Your suggestion helped for
certain files. Certainly in the files I have to test with, in every
case where doc.Revisions.Count > 0, I would experience the Command
failure.

I'm still hoping to find some other properties or methods I can use to
find/avoid other causes.
Thanks so much,
Christine
 
R

Raj

Hi

I have the same problem but my context is this:

The vba code is in Excel. The aim is to list all word documents that exist
in a folder and check if they are password protected. It is able to open the
document but when asked for the password, if cancel is pressed or the
password is wrong, I get 4198. I have put all types of error trapping.
 

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