Copy Code code as follows:
/*
To a few JS write word reference:
this. Word.Selection.Font.Size = 16; Font size
this. Word.Selection.Font.Bold = true; Whether Bold
this. Word.Selection.ParagraphFormat.Alignment = 2; 0 left Alignment, 1 center, 2 right alignment, the number can only 0-9, slowly try it
this. Word.Selection.InsertRowsBelow (1); Add a line below
this. Word.Selection.MoveRight (1); Move the cursor to the right
this. Word.Selection.TypeText (string); can only write string
this. Word.Selection.MoveDown (); Move Cursor Down
this. Word.Selection.EndKey (); The cursor moves to the end
this. Word.ActiveDocument.Sections (1). Headers (1). Range.InsertAfter (string); Write a header, write at the end
this._loaddata = function () {
//substitution function, used to replace $strfld$ type of text
function replace (Range, strfld) {
//[findtext], [matchcase], [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [matchallwordforms], [Forward], [ Wrap], [Format], [replacewith], [Replace], [MatchKashida], [MatchDiacritics], [MatchAlefHamza], [Matchcontrol]
range.find.execute ("$" +strfld+ "$", true, False, False, False, False, True, Wdfindcontinue, False, Getelvalue ("L" +strf LD))
£}
//to initialize a 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 the user cancels the ActiveX operation manually, a WINWORD.EXE process will be left.
//The ActiveX-enabled dialog box does not appear unless "set as a trusted site and the second item is enabled at the custom level."
try {
if (this. DOC) {this. Doc.close (0)};
if (this. Word) {this. Word.quit ()}
£}
catch (e) {}
return false
£}
£}
*/