Tag: docvariable

使用C#填写Word docx中的docvariable

我已经在VB 6中完成了这一百次,但它让我疯狂使用C#2008和Word 2007.我创建了一个带有两个docvariables的docx文件: Some text here…. {docvariable replace1} {docvariable replace2} More text here…… 我首先创建了一个宏来做它并且它有效: Sub FillDocVariable() ‘ ‘ FillDocVariable Macro ‘ ‘ ActiveDocument.Variables(“replace1”).Value = “This is a test” ActiveDocument.Variables(“replace2”).Value = “it is only a test.” ActiveDocument.Fields.Update End Sub 这是我的C#代码(请注意,我正在学习这个代码): using Microsoft.Office.Interop.Word; object paramMissing = Type.Missing; object openfileName = @”C:\testing\Documents\1.docx”; ApplicationClass WordApplication = new ApplicationClass(); Document […]