Copy codeThe Code is as follows:
/*
A reference for writing word to several js files:
This. Word. Selection. Font. Size = 16; // Font Size
This. Word. Selection. Font. Bold = true; // whether to Bold
This. Word. Selection. ParagraphFormat. Alignment = 2; // 0: Left Alignment; 1: center; 2: Right Alignment; number: 0-9; try it slowly
This. Word. Selection. InsertRowsBelow (1); // Add a row below
This. Word. Selection. MoveRight (1); // move the cursor right
This. Word. Selection. TypeText (string); // only string can be written.
This. Word. Selection. MoveDown (); // move the cursor down
This. Word. Selection. EndKey (); // move the cursor to the end
This. Word. ActiveDocument. Sections (1). Headers (1). Range. InsertAfter (string); // write the header at the end
This. _ LoadData = function (){
// Replacement function, used to replace $ strFld $ text
Function replace (Range, strace ){
// [FindText], [MatchCase], [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [MatchAllWordForms], [Forward], [Wrap], [Format], [ReplaceWith], [Replace], [MatchKashida], [MatchDiacritics], [MatchAlefHamza], [MatchControl]
Range. find. execute ("$" + strute + "$", true, false, true, wdFindContinue, false, getElValue ("l" + strute ))
}
// Initialize the Word Control
This. _ InitWord = function ()
{
Try {
This. Word = new ActiveXObject ("Word. Application ");
This. Word. visible = true;
This. Doc = this. Word. Documents. Open (this. TemplatePath );
This. Doc. Activate ();
This. Range = this. Doc. Range ();
Return true
} Catch (e ){
// TODO: If you manually cancel running ActiveX, a winword. EXE process will be left.
// The ActiveX activation dialog box does not appear unless "set as a trusted site and enable item 2 at the custom level.
Try {
If (this. Doc) {this. Doc. Close (0 )};
If (this. Word) {this. Word. Quit ()}
}
Catch (e ){}
Return false
}
}
*/