Several JavaScript manipulating Word's reference code _javascript tips

Source: Internet
Author: User
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
£}
£}
*/
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.