更新字编号:的Microsoft.Office.Interop.Word [英] Update word Ref: Microsoft.Office.Interop.Word

查看:264
本文介绍了更新字编号:的Microsoft.Office.Interop.Word的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我使用的Microsoft.Office.Interop.Word库自动填充文成Word模板形式(。 。DOTX)

I am using the Microsoft.Office.Interop.Word library to automatically fill text into a Word template form (.dotx).

当我正在填充文字的形式我使用MS Word中的书签是这样的:

When i am filling the form with text i use MS Word bookmarks like this:

object oBookMark = "Bookmark-To-Find";
doc.FormFields.get_Item(ref oBookMark).Result = Value-To-Insert;

这工作没有任何问题,的问题是,当我一个微软Word引用添加到书签。

This works without any problems, the problem is when i add a MS Word reference to the bookmark.

基准是有,所以我并不需要在同一文件中填写相同信息的100倍。

The reference is there so i don't need to fill out same information 100 times in the same document.

MS Word中需要参考在创建文档时手动更新。
反正是有解决这个问题。

The MS Word Reference needs to be manually updated when the document is created. Is there anyway to fix this?

问题:
我可以更新与C#代码的所有引用?
是有没有更好的办法,使这个

Questions: Can i update all references with c# code? Is there any better way to make this?

推荐答案

您需要更新文档中的所有领域:

You need to update all fields in the document:

doc.Fields.Update();

您也可以只通过调用各自领域内的Update()方法更新特定领域 doc.Fields 集合。

You can also update particular fields only by calling the Update() method of the respective fields within the doc.Fields collection.

这篇关于更新字编号:的Microsoft.Office.Interop.Word的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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