Use JScript to create and save a Word document

Source: Internet
Author: User

Demonstration script that retrieves network adapter data from a computer,
Displays that data in a Microsoft Word document, and then saves
Document as c: \ scripts \ word \ testdoc.doc. CopyCode The Code is as follows: Set objword = Createobject ("word. application ")
Objword. Caption = "test caption"
Objword. Visible = true

Set objdoc = objword. Documents. Add ()
Set objselection = objword. Selection

Objselection. Font. Name = "Arial"
Objselection. Font. size = "18"
Objselection. typetext "network adapter Report"
Objselection. typeparagraph ()

Objselection. Font. size = "14"
Objselection. typetext "" & date ()
Objselection. typeparagraph ()
Objselection. typeparagraph ()

Objselection. Font. size = "10"

Strcomputer = "."
Set ob1_miservice = GetObject ("winmgmts: \" & strcomputer & "\ Root \ cimv2 ")
Set colitems = obw.miservice. execquery _
("Select * From win32_networkadapterconfiguration ")

For each objitem in colitems

Objselection. Font. Bold = true
Objselection. typetext "ARP always source route :"
Objselection. Font. Bold = false
Objselection. typetext "" & objitem. arpalwayssourceroute
Objselection. typeparagraph ()

Objselection. Font. Bold = true
Objselection. typetext "ARP use ethersnap :"
Objselection. Font. Bold = false
Objselection. typetext "" & objitem. arpuseethersnap
Objselection. typeparagraph ()

Objselection. Font. Bold = true
Objselection. typetext "caption :"
Objselection. Font. Bold = false
Objselection. typetext "" & objitem. Caption
Objselection. typeparagraph ()

Objselection. Font. Bold = true
Objselection. typetext "database path :"
Objselection. Font. Bold = false
Objselection. typetext "" & objitem. databasepath
Objselection. typeparagraph ()

Objselection. Font. Bold = true
Objselection. typetext "Dead GW Detection Enabled :"
Objselection. Font. Bold = false
Objselection. typetext "" & objitem. deadgwdetectenabled
Objselection. typeparagraph ()

Objselection. Font. Bold = true
Objselection. typetext "default IP Gateway :"
Objselection. Font. Bold = false
Objselection. typetext "" & objitem. defaultipgateway
Objselection. typeparagraph ()

Objselection. Font. Bold = true
Objselection. typetext "Default TOS :"
Objselection. Font. Bold = false
Objselection. typetext "" & objitem. defaulttos
Objselection. typeparagraph ()

Objselection. Font. Bold = true
Objselection. typetext "Default TTL :"
Objselection. Font. Bold = false
Objselection. typetext "" & objitem. defaultttl
Objselection. typeparagraph ()

Objselection. Font. Bold = true
Objselection. typetext "Description :"
Objselection. Font. Bold = true
Objselection. Font. Bold = false
Objselection. typetext "" & objitem. Description
Objselection. typeparagraph ()

Objselection. typeparagraph ()

Next

Objdoc. saveas ("C: \ scripts \ word \ testdoc.doc ")
Objword. Quit

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.