C#操作word 打印 打印预览
(2010-11-27 15:25:29)
/// word 应用对象
///
private Microsoft.Office.Interop.Word.Application _wordApplication;
///
/// word 文件对象
///
private Microsoft.Office.Interop.Word.Document _wordDocument;
///
/// 创建文档
///
public void CreateAWord()
{
//实例化word应用对象
this._wordApplication = new
Microsoft.Office.Interop.Word.ApplicationClass();
Object myNothing = System.Reflection.Missing.Value;
this._wordDocument = this._wordApplication.Documents.Add(ref
myNothing, ref myNothing, ref myNothing, ref myNothing);
//_wordDocument. = _wordApplication.bo;
//Microsoft.Office.Interop.Word.Border=;
//bo.Color = Color.Black;
//bo.LineStyle = 1;
}
///
/// 添加页眉
///
///
public void SetPageHeader(string pPageHeader)
{
//.wdOutlineView,wdSeekPrimaryHeader;
//添加页眉
this._wordApplication.ActiveWindow.View.Type =
Microsoft.Office.Interop.Word.WdViewType.wdOutlineView;
this._wordApplication.ActiveWindow.View.SeekView =
Microsoft.Office.Interop.Word.WdSeekView.wdSeekPrimaryHeader;
//this._wordApplication.ActiveWindow.ActivePane.Selection.InsertAfter(pPageHeader);
//设置中间对齐
this._wordApplication.Selection.ParagraphFormat.Alignment =
Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphCenter;
//跳出页眉设置
this._wordApplication.ActiveWindow.View.SeekView =
Microsoft.Office.Interop.Word.WdSeekView.wdSeekMainDocument;