again: ContentControlAfterAdd won't let me access WordApplication.Documents

D

David Thielen

In my ContentControlAfterAdd event handler, when I hit undo which
brings back a ContentControl that I had deleted, the code:

foreach (Document doc in applicationObject.Documents)

Throws the exception:
System.Runtime.InteropServices.COMException occurred
HelpLink="C:\\Program Files\\Microsoft
Office\\Office12\\1033\\WDMAIN11.CHM#25677"
Message="This object model command is not available while in the
current event."
Source="Microsoft Word"
ErrorCode=-2146822091
StackTrace:
at
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
errorCode, IntPtr errorInfo)
at
System.Runtime.InteropServices.CustomMarshalers.EnumerableViewOfDispatch.GetEnumerator()
at System.Collections.IEnumerable.GetEnumerator()
at
AutoTag2010.net.windward.autotag.word.WordFramework.Document_ContentControlAfterAdd(ContentControl
ctrl, Boolean InUndoRedo) in
C:\src\version9\AutoTag\AutoTag2010\net\windward\autotag\word\WordFramework.cs:line
120
InnerException:

There is nothing nested - this is a direct call from Word and is not
inside other calls made by my AddIn. I have just one Word document
open.

Any ideas?

thanks - dave

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

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