导入COM库:Microsoft word 11.0 Object Library.
创建新Word






ref oMissing, ref oMissing);










导入模板








.添加新表












.表插入行
















.单元格合并



















.单元格分离
























word文档内容替换

public bool Replace(string strOldText,string strNewText)
{
this.oDoc.Content.Find.Text = strOldText ;
object FindText, ReplaceWith, Replace ;//
object MissingValue = Type.Missing;
FindText = strOldText ;//要查找的文本
ReplaceWith = strNewText ;//替换文本
Replace = Word.WdReplace.wdReplaceAll ;/*wdReplaceAll - 替换找到的所有项。
* wdReplaceNone - 不替换找到的任何项。
* wdReplaceOne - 替换找到的第一项。
* */
this.oDoc.Content.Find.ClearFormatting();//移除Find的搜索文本和段落格式设置
if (this.oDoc.Content.Find.Execute(
ref FindText,ref MissingValue,
ref MissingValue,ref MissingValue,
ref MissingValue,ref MissingValue,
ref MissingValue,ref MissingValue,ref MissingValue,
ref ReplaceWith,ref Replace,
ref MissingValue,ref MissingValue,
ref MissingValue,ref MissingValue))
{
return true ;
}
return false ;
通过段落控制插入

















oPara1.Range.InsertParagraphAfter();