在 word 脚注中并排添加字段

Adding fields side by side in word footnote

您好,我的 word 应用程序有问题。我试图在脚注中并排添加一个字段。我遇到的问题是合并冲突,我认为这是因为范围相同并且超出了另一个领域。我正在尝试根据前一个字段的终点将它们并排添加到一行中。

我试过将范围缩小到最后,但我无法让它工作。任何帮助将不胜感激,因为我刚开始使用 VSTO 工具,但我发现它们不是很好。

   public static void insertHtmlIntoFootnoteResult (Field field, List<ct> 
        list)
       {     
      for(var c in ct){
           //I am trying to go to the end here
        field.Result.Collapse(WdCollapseDirection.wdCollapseEnd); 

        //How do I create a new field and insert it here based of the the 
        //last fields ending position?
        string guid = Guid.NewGuid().ToString();
        var filename = Path.GetTempPath() + "temp" + guid + ".html";
        using (StreamWriter s = File.CreateText(filename))
        {
            s.Write("I am test");
            s.Close();
        }                 
        field.Result.InsertFile(filename);

        File.Delete(filename);

       }
    } // _insertHtmlIntoRange

嘿,所以我最终使用 flowerspost 的博客

找到了答案

https://gist.github.com/FlorianWolters/6257233

通过更改 insertempty() 方法以插入 Word.WdFieldType.wdFieldIf 字段来完成。

希望对以后的人有所帮助!