日期:2014-05-17 浏览次数:21122 次
Microsoft.Office.Interop.Word.Application app = null;
Microsoft.Office.Interop.Word.Document doc = null;
object missing = System.Reflection.Missing.Value;
object templateFile = Application.StartupPath + @"\模版.doc";
try
{
app = new Microsoft.Office.Interop.Word.ApplicationClass();
doc = app.Documents.Add(ref templateFile, ref missing, ref missing, ref missing);
try
{//在Word中输入文字,现在所要插入文字处插入书签用以定位
foreach (Microsoft.Office.Interop.Word.Bookmark bm in doc.Bookmarks)
{
if (bm.Name == "插入的书签名")
{
bm.Select();
bm.Range.Text = "要在书签处插入的文字";
}
}
}
catch { }
//打印
doc.PrintOut(ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing,
&