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.
Copy codeThe 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