2010年和2013年之间的Word加载项兼容性问题 [英] Word add-in compatibility issues between 2010 and 2013

查看:166
本文介绍了2010年和2013年之间的Word加载项兼容性问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Word插件,可以从服务器下载内容并将其显示在文档中的不同书签中。该内容作为一组在Aspose中创建的临时书签下载到"ScratchArea"中。书签,然后代码
将这些临时书签复制到文档中的永久书签。然后,我写了一个名为"InsertTextIntoBookmark"的函数。 :

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,"  ");

documentUtility.InsertTextIntoBM(ScratchArea, "     ");

public void InsertTextIntoBM(Bookmark bookmark,string text)

        {

            string bookmarkName = bookmark.Name;

            if(string.IsNullOrWhiteSpace(text))

                text = OneSpace;

            UnlockDocument();

           范围insertRange = bookmark.Range;

            insertRange.Text = text;

            _document.Bookmarks.Add(bookmarkName,insertRange);
$


            LockDocument();

        } 

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();
        } 

基本上清除了"ScratchArea"。书签并变为"不可见"对于用户。 

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

这在Word 2010中没有任何问题。但是,在Word 2013中,"InsertTextIntoBookmark"功能不是清除"ScratchArea"中的数据。书签,以便当文档完全加载时,"ScratchArea"中的信息被写入。
已被复制到文档中各自的书签,但是"ScratchArea"数据仍然存在。 

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. 

另外,我不想只是删除这个"ScratchArea"。 bookmark,因为用户可以选择从服务器重新下载内容。我只是想清除它的所有内容。

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.

谢谢

推荐答案

你好Luke415,

根据我的测试在单词2013中,它工作正常。您是否可以在新项目中重现该问题? 您可以在OneDrive上共享它。

简单代码:

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);

你说它没有"清除"书签的数据(替换为空格),它在单词2013中有效但在单词2013中不起作用,我认为问题可能在
insertRange 对象的Text值中,所以请调试您的应用程序,以便在为其设置空白字符串后检查文本的值(与
OneSpace 相关)和 insertRange.Text 值。

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.

问候

Starain


这篇关于2010年和2013年之间的Word加载项兼容性问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆