Home  >  Article  >  Web Front-end  >  Several reference codes for javascript operations on word_javascript skills

Several reference codes for javascript operations on word_javascript skills

WBOY
WBOYOriginal
2016-05-16 18:43:16895browse
Copy code The code is as follows:

/*
A reference for several js writing words :
this.Word.Selection.Font.Size = 16; //Font size
this.Word.Selection.Font.Bold = true; //Whether to bold
this .Word.Selection.ParagraphFormat.Alignment = 2; //0 is left aligned, 1 is centered, 2 is right aligned, numbers can only be 0-9, try it slowly
this.Word.Selection.InsertRowsBelow(1) ; //Add a line below
this.Word.Selection.MoveRight(1); //Move the cursor right
this.Word.Selection.TypeText(string); //Only strings can be written
this.Word.Selection.MoveDown(); //The cursor moves down
this.Word.Selection.EndKey(); //The cursor moves to the end
this.Word.ActiveDocument .Sections(1).Headers(1).Range.InsertAfter(string); //Write the header, and write
this._LoadData = function () {
//Replace the function, Used to replace text of type $strFld$
 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" strFld) )
 }
//Initialize 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 manually cancels the running of ActiveX, a WINWORD.EXE process will be left. .
 //Unless "Set as a trusted site and enable the second item in the custom level", the dialog box to enable ActiveX will not appear.
 try {
 if ( this.Doc ) { this.Doc.Close(0) };
 if ( this.Word ) { this.Word.Quit() }
 }
 catch (e){}
 return false
 }
 }
*/
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn