locked
Word Bookmark reinsert. RRS feed

  • Question

  •  

    Hello all,

     

    i'm currently working on a VSTO(C#) project, i have a treeview and when i drop a node into the Word doc it creates a bookmark, everything working well, so far i noticed a problem, when i delete the bookmarked text and i try to reinsert the same node, i got an error telling me that the bookmark exists in the ControlCollection.

     

     i tried to remove it from the collection and reinsert it, when remove it i got an error message telling me that removing this control could affect some areas in the word document.

     

    my question is:

     

    how can i reinsert the same bookmark after deleting it.

    Thursday, January 17, 2008 10:21 AM

Answers

  • Hello Cindy,

     

    thank you for your reply,

     

    Actually i resolved the problem:

     

    i was using WordDocument1.thisDocument.Controls.AddBookmark() which is causing the problem.

     

    Now i replaced it with: _WordDocument1.thisDocument.ThisApplication.ActiveDocument.Bookmarks.Add();

     

    which is correct Smile

     

     

     

     

     

    Friday, January 18, 2008 12:07 PM

All replies

  • VSTO 2005 or 2008? Word 2003 or 2007?

     

    Please show us the code you're using to create the bookmark when you "drop a node into the Word doc".

     

    It sounds like you're creating a VSTO Bookmark control, rather than a "plain Word bookmark". The VSTO control wraps the Word bookmark and provides some additional functionality: Do you need this functionality? If not, it might make more sense to create a "plain Word bookmark", instead...

     

    Thursday, January 17, 2008 5:43 PM
  • Hello Cindy,

     

    thank you for your reply,

     

    Actually i resolved the problem:

     

    i was using WordDocument1.thisDocument.Controls.AddBookmark() which is causing the problem.

     

    Now i replaced it with: _WordDocument1.thisDocument.ThisApplication.ActiveDocument.Bookmarks.Add();

     

    which is correct Smile

     

     

     

     

     

    Friday, January 18, 2008 12:07 PM