Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all articles
Browse latest Browse all 1741

New Post: How not dispose of child objects?

$
0
0
You have another option:
using (NetOffice.WordApi.Bookmarks bookmarks = doc.Bookmarks)
{
     foreach (NetOffice.WordApi.Bookmark bookmark in bookmarks)
     {
          if (bookmark.Name.StartsWith(prefix))
         {
               bookmarkList.Add(bookmark);
               
               // remove bookmark proxy from its parent
               bookmark.Parent.RemoveChildObject(bookmark);

              // now you have to make sure dispose is called for the bookmark at hand
              // otherwise you can re-add the bookmark (as child) to another proxy instance
              // in this case doc for example:
              doc.AddChildObject(bookmark);
         }
     }
}
*Sebastian

Viewing all articles
Browse latest Browse all 1741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>