CAPI Exception 0x800A2388 - ActiveDocument.TrackRevisions = false

F

Fruber Malcome

I get the mentioned exception when trying to set TrackRevisions of the
ActiveDocument to false.

Does anyone know why?

thanks - Fruber
 
C

Cindy M -WordMVP-

Hi Fruber,
I get the mentioned exception when trying to set TrackRevisions of the
ActiveDocument to false.
Please show us the exact code you're using, tell us which version of
Word, and describe the circumstances involving the document (what you've
been doing with it up to that point). I'm not familiar with CAPI and CMI
- just looked it up in a KB article). But that article says it allows
cross-process and asynchronous calls. That can cause problems with Word
if the app is not in a state ready to accept the call. In that case, you
have to let things "sleep" a while, until Word can catch up.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 
F

Fruber Malcome

That's interesting - and may hit a point.
I have a handler that's called when a button is cliked (for the sake of
clarity - Fill-In Fields)

What's interesting is that even the function _protectDocument failes (more
precisly: _thisApplication.ActiveDocument.Protect( type, ref objNoReset, ref
objPass, ref objMissing, ref objMissing ); )

As you can see in my comments, I get the CAPI on the TrackRevisions, but
interestingly the Product fails with a different exception - I get an error
stating that this function cannot be performed because a macro is already
running.)

Just so that you know even more about what's going on, I have a generic
button handler for all commandbar clicks. Each button has an OnAction
propery that is a text (of the actual function) - I use reflection to invoke
this function. But to get to the point, I launch this in it's own thread.

Because the handler's aparement is MTA, and I need STA for some
functionality, plus I get a better UI performance when I use a seperate
thread. I've include my button handler class as well. You should be able
to tell, that I use the MethodInfo from reflection as a parameter to my
thread object (also below) so that I can perform these tasks centrally (code
reuse).

Hopefully this gives you plenty to work from, any help would be grealty
appreciated...

thanks Cindy!
Fruber



Function impl below:
private void _fillInForm()
{
Debug.WriteLine( "_fillInForm()" );

_setButtonState( LegalLibrary.CommandBarControl.TBTAG_FILLIN_FIELDS,
Office.MsoButtonState.msoButtonDown );
_setButtonState( LegalLibrary.CommandBarControl.TBTAG_EDIT_TEXT,
Office.MsoButtonState.msoButtonUp );
_setButtonState( LegalLibrary.MenuBarControl.MBTAG_FILLIN_FIELDS,
Office.MsoButtonState.msoButtonDown );
_setButtonState( LegalLibrary.MenuBarControl.MBTAG_EDIT_TEXT,
Office.MsoButtonState.msoButtonUp );

// TODO: was getting CAPI exception on next line?
//_thisApplication.ActiveDocument.TrackRevisions = false;

// TODO: was getting exception because a macro is currently running?
//_protectDocument( Word.WdProtectionType.wdAllowOnlyFormFields );

}

public class ButtonHandler
{
static public void handleClickEvent( MethodInfo mi, object objClass )
{
Thread t = CThread.CreateThread( new CThread.Start( _handleClickEvent ),
new object[]{mi,objClass} );
t.ApartmentState = ApartmentState.STA;
t.Name = String.Format( "{0}_Thread", mi.Name );
t.Start();
}
static private void _handleClickEvent( object[] args )
{
MethodInfo mi = args[0] as MethodInfo;
object objClass = args[1];

mi.Invoke( objClass, new object[]{} );
}
}
public class CThread
{
public delegate void Start( object[] o );

private class Args
{
public object[] o;
public Start s;
public void work(){ s(o); }
}// end of private class Args
public static Thread CreateThread( Start s, object[] args )
{
Args a = new Args();

a.o = args;

a.s = s;
Thread t = new Thread( new ThreadStart( a.work ) );
return t;
}// end of CreateThread
}// end of class CThread
 

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