参照下面录制的宏修改If ActiveWindow.View.SplitSpecial = wdPaneNone Then ActiveWindow.ActivePane.View.Type = wdPrintView Else ActiveWindow.View.Type = wdPrintView End If If ActiveWindow.View.SplitSpecial <> wdPaneNone Then ActiveWindow.Panes(2).Close End If If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _ ActivePane.View.Type = wdOutlineView Then ActiveWindow.ActivePane.View.Type = wdPrintView End If ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader Selection.TypeText Text:="刘" & vbTab NormalTemplate.AutoTextEntries("- PAGE -").Insert Where:=Selection.Range ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
楼上的是一种方法; 还有更好的一种方法,就是先做一个摸板把这些属性设置好,然后直接用此摸板创建一个文件就可以了,省得写代码。 var V: OleVariant; try V := CreateOleObject('Word.Application'); except ShowMessage('您还没有安装MicroSoft Word!'); Abort; end; V.Application.Documents.Add(ExtractFilePath(Application.ExeName)+'dot\document.dot');
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.TypeText Text:="刘" & vbTab
NormalTemplate.AutoTextEntries("- PAGE -").Insert Where:=Selection.Range
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
还有更好的一种方法,就是先做一个摸板把这些属性设置好,然后直接用此摸板创建一个文件就可以了,省得写代码。
var
V: OleVariant; try
V := CreateOleObject('Word.Application');
except
ShowMessage('您还没有安装MicroSoft Word!');
Abort;
end;
V.Application.Documents.Add(ExtractFilePath(Application.ExeName)+'dot\document.dot');