NTKO word線上文字編輯控制元件寫頁首頁尾
//Section.Footers 屬性
//返回一個 HeadersFooters 集合,該集合代表指定節的頁尾
//Section.Headers 屬性
//返回一個 HeadersFooters 集合,該集合代表指定節的頁首
//WdHeaderFooterIndex 列舉
//返回文件或節中的指定頁首或頁尾。
//名稱 值 描述
//wdHeaderFooterEvenPages 3 返回偶數頁上的所有頁首或頁尾。
//wdHeaderFooterFirstPage 2 返回文件或節中的第一個頁首或頁尾。
//wdHeaderFooterPrimary 1 返回文件或節中除第一頁外所有頁上的頁首或頁尾。
//Sections 集合包括所選內容、範圍或文件中的所有節。
//Section 代表所選內容、範圍或文件中的一節
//View 包含視窗或窗格的檢視屬性(如全部顯示、域底紋和網格線)。
//SeekView 屬性可檢視批註、尾註、腳註或者文件頁首或頁尾
//WdSeekView 列舉
//指定要在頁面檢視中顯示的文件元素。
//名稱 值 描述
//wdSeekCurrentPageFooter 10 當前頁頁尾。
//wdSeekCurrentPageHeader 9 當前頁頁首。
//wdSeekEndnotes 8 尾註。
//wdSeekEvenPagesFooter 6 偶數頁頁尾。
//wdSeekEvenPagesHeader 3 偶數頁頁首。
//wdSeekFirstPageFooter 5 首頁頁尾。
//wdSeekFirstPageHeader 2 首頁頁首。
//wdSeekFootnotes 7 腳註。
//wdSeekMainDocument 0 主文件。
//wdSeekPrimaryFooter 4 主頁尾。
//wdSeekPrimaryHeader 1 主頁首。
WdPageNumberAlignment 列舉
//指定要應用於頁碼的對齊方式。
//名稱 值 描述
//wdAlignPageNumberCenter 1 居中。
//wdAlignPageNumberInside 3 只在頁尾內部左對齊。
//wdAlignPageNumberLeft 0 左對齊。
//wdAlignPageNumberOutside 4 只在頁尾外部右對齊。
//wdAlignPageNumberRight
//HeadersFooters 集合物件
//HeaderFooter 物件的集合,這些物件代表文件的指定節中的頁首或頁尾
//Shapes.AddTextEffect 方法
//在繪圖畫布上新增一個“藝術字”圖形。返回一個 Shape 物件,該物件代表“藝術字”,並將其新增至 CanvasShapes 集合。
//Window.ActivePane 屬性
//返回 Pane 物件,該物件代表指定視窗的活動窗格;一個代表 Window 物件的變數。
//ActiveWindow 屬性 返回開發環境中活動的視窗
//Application.ActiveDocument 屬性
//返回一個 Document 物件,該物件代表活動文件。如果沒有開啟的文件,就會導致出錯。
//Range 物件
//代表文件中的一個連續區域。每個 Range 物件由一個起始字元位置和一個終止字元位置定義。
//WdParagraphAlignment 列舉
//指定段落的對齊方式。
//名稱 值 描述
//wdAlignParagraphCenter 1 居中。
//wdAlignParagraphDistribute 4 段落字元被分佈排列,以填滿整個段落寬度。
//wdAlignParagraphJustify 3 完全兩端對齊。
//wdAlignParagraphJustifyHi 7 兩端對齊,字元高度壓縮。
//wdAlignParagraphJustifyLow 8 兩端對齊,字元輕微壓縮。
//wdAlignParagraphJustifyMed 5 兩端對齊,字元中度壓縮。
//wdAlignParagraphLeft 0 左對齊。
//wdAlignParagraphRight 2 右對齊。
//wdAlignParagraphThaiJustify 9 按照泰語格式佈局兩端對齊。
//ParagraphFormat 物件
//代表段落的所有格式。
//說明:使用 Format 屬性可返回一個或多個段落的 ParagraphFormat 物件。ParagraphFormat 屬性返回所選內容、範圍、樣式、 Find 物件或 Replacement
物件的 ParagraphFormat 物件。
//Selection.TypeText 方法
//插入指定的文字
//Fields.Add 方法
//將 Field 物件新增到 Fields 集合
程式碼示例:
function ADDReport()
{
try
{
var ActiveDocument = form1.TANGER_OCX.ActiveDocument;
ActiveDocument.Sections(1).Headers(2).Range.Borders(-3).LineStyle = 0;
ActiveDocument.Sections(1).Footers(2).Range.Delete();
insertPageFooter();
for (i=1;i<=ActiveDocument.Sections.Count ; i++)
{
ActiveDocument.Sections(i).Range.Select();
ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 10;
ActiveDocument.Sections(i).Headers(1).Range.Borders(-3).LineStyle = 0;
ActiveDocument.Sections(i).Footers(1).Range.Delete();
insertPageFooter();
}
}
catch(err){
alert("ADDReport errir:" + err.number + ":" + err.description);
}
}
function insertPageFooter()
{
var ActiveDocument = form1.TANGER_OCX.ActiveDocument;
var App=form1.TANGER_OCX.ActiveDocument.Application;
ActiveDocument.ActiveWindow.ActivePane.View.SeekView=10;
App.Selection.ParagraphFormat.Alignment=1;
App.Selection.TypeText("說明 第");
App.Selection.Fields.Add(App.Selection.Range,33);
App.Selection.TypeText("頁 ");
App.Selection.TypeText("<% =GetProjCheckCode() %>");
ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 0;
}