This predefined bookmark is available for the active document only.

D

David Thielen

I am walking all content controls in the document using:
foreach (ContentControl ctrl in range.ContentControls)

On some of them I get:
+ $exception {"This predefined bookmark is
available for the active document only."} System.Exception
{System.Runtime.InteropServices.COMException}

when I try to access ctrl.Range.

These are content controls I created and added to the document. Why do
I get this error?

thanks - dave

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

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

David Thielen

Document with the problem at
http://www.windwardreports.com/temp/WeirdContentControl.zip

thanks - dave


I am walking all content controls in the document using:
foreach (ContentControl ctrl in range.ContentControls)

On some of them I get:
+ $exception {"This predefined bookmark is
available for the active document only."} System.Exception
{System.Runtime.InteropServices.COMException}

when I try to access ctrl.Range.

These are content controls I created and added to the document. Why do
I get this error?

thanks - dave

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

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


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

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

Ji Zhou

Very strange issue. I can reproduce the issue in Word 2007 SP2, but not Word
2010. This issue is a little hard to debug and investigate. I have used some
time to research and study, but have not found anything special. I will do
some more investigations and update with you later.

Have a nice day!

Best regards,
Ji Zhou
Microsoft Online Community Support
 
J

Ji Zhou

Hello Dave,

With some further debugging, I found the issue was caused by a corrupted
content control in the document. I have located the content control, copy it
to another document, and delete it from the original document. Then I can
loop the original document's ContentControl collection and access their
range properties without any problems.

Here is the updated document,
http://cid-c2e0d62e8a095a30.skydrive.live.com/self.aspx/Public/support^_test.docx

And here is the new document with the copied content control which is
corrupted,
http://cid-c2e0d62e8a095a30.skydrive.live.com/self.aspx/Public/test.docx

If you run your codes again, you are expected to see that the first document
work well and the second document fails.

Since it is a content control corrupted issue, I think the easiest solution
would be deleting that one and create a new one. If you would like to know
why the content control is corrupted, I think we need to know how the
content control is generated and whether it can be reproduced in some fixed
steps.


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support
 
D

David Thielen

We had a user send us this and they aren't real sure what happened. My
worry is not failing when we hit this - I gues we'll have to do a
try/catch.

thanks - dave


Hello Dave,

With some further debugging, I found the issue was caused by a corrupted
content control in the document. I have located the content control, copy it
to another document, and delete it from the original document. Then I can
loop the original document's ContentControl collection and access their
range properties without any problems.

Here is the updated document,
http://cid-c2e0d62e8a095a30.skydrive.live.com/self.aspx/Public/support^_test.docx

And here is the new document with the copied content control which is
corrupted,
http://cid-c2e0d62e8a095a30.skydrive.live.com/self.aspx/Public/test.docx

If you run your codes again, you are expected to see that the first document
work well and the second document fails.

Since it is a content control corrupted issue, I think the easiest solution
would be deleting that one and create a new one. If you would like to know
why the content control is corrupted, I think we need to know how the
content control is generated and whether it can be reproduced in some fixed
steps.


Best regards,
Ji Zhou - MSFT
Microsoft Online Community Support


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