none
Word add-in compatibility issues between 2010 and 2013 RRS feed

  • Question

  • Hi,  I have a Word addin that downloads content from a server and displays it in different bookmarks within the document. The content is downloaded as a group of temporary bookmarks created in Aspose to a "ScratchArea" bookmark, then the code copies these temporary bookmarks to their permanent bookmarks in the document. Then, there is a function I have written called "InsertTextIntoBookmark" :

    documentUtility.InsertTextIntoBM(ScratchArea, "     ");

    public void InsertTextIntoBM(Bookmark bookmark, string text)
            {
                string bookmarkName = bookmark.Name;
                if (string.IsNullOrWhiteSpace(text))
                    text = OneSpace;
                UnlockDocument();
                Range insertRange = bookmark.Range;
                insertRange.Text = text;
                _document.Bookmarks.Add(bookmarkName, insertRange);

                LockDocument();
            } 

    that essentially clears the "ScratchArea" bookmark and becomes "invisible" to the user. 

    This has worked without any problem in Word 2010. However, in Word 2013 the "InsertTextIntoBookmark" function is not clearing the data in the "ScratchArea" bookmark, so that when the document fully loads, the information within the "ScratchArea" has been copied to their respective bookmarks in the doc, but the "ScratchArea" data remains there. 

    Also, I do not want to just delete this "ScratchArea" bookmark because the user has the option to reload content down from the server. I simply want to clear all of its content.

    Thank you

    Monday, January 4, 2016 2:30 PM

All replies

  • Hi Luke415,

    Based on my test in word 2013, it works fine. Could you reproduce that issue in a new project? You may share it on the OneDrive.

    Simple code:

    Word.Document doc = Application.ActiveDocument;
                Word.Bookmark bm = doc.Bookmarks[1];
                Word.Range r = bm.Range;
                string name = bm.Name;
                r.Text = " ";   
                doc.Bookmarks.Add(name, r);

    You said that it doesn’t “clear” the data of the bookmark (replace to whitespace), it works in word 2013 but not in word 2013, I think the issue may is in the Text value of insertRange object, so please debug your application to check the value of text (related to OneSpace) and the insertRange.Text value after set the whitespace string to it.

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    Tuesday, January 5, 2016 6:54 AM
    Moderator
  • Hi Luke

    <<Also, I do not want to just delete this "ScratchArea" bookmark because the user has the option to reload content down from the server. I simply want to clear all of its content.>>

    You need to be more specific about what the '"ScratchArea" bookmark' is. It's not possible in Word to "clear bookmark content". A [bookmark] with no content will be deleted automatically. Only a Ibookmark can stand alone - but then the bookmark won't contain anything - it's just a "marker".

    Since "ScratchArea" is something created by third-party software there's no way for us to know what's going on and how it's supposed to be used.

    You also do not provide any code that has anything to do with the "ScratchArea" - at least, not that I can see...


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Friday, January 8, 2016 5:10 PM
    Moderator