;=======================================================================================
; Name : PCInventory.kix
; Author : SBLAETTL
; Date : 14.11.2013
; Purpose : Prints a paper with all relevant data of a redeployable asset
; Ext. Dependencies :
;
;-------------------------------------------------------------------------------
; Changes:
; Author Date
;=========================================================================================
Break on
Dim $Ret
$Ret = SetOption("Explicit", "on")
Dim $objWordApp
Dim $objWordDoc
Dim $objDoc
Dim $Template
$objWordApp = CreateObject("Word.Application")
If @ERROR <> 0
$ret = MessageBox("unable to start Word on this device, terminating", "Problem with Office")
Quit
EndIf
$Template = @SCRIPTDIR + "\Asset Tag.dotx"
If Not(Exist($Template))
$ret = MessageBox("unable to find template " + $Template + ", terminating", "Problem with configuration")
Quit
EndIf
$ObjWordDoc = $objWordApp.Application.Documents.Add($Template)
Dim $oField
For Each $oField in $objWordDoc.Fields
? "Field name :" + $ofield.name
Next
$Ret = $objWordDoc.Variables.item["AssetTag"].Value = "SomeAssetTagInfo"
$Ret = $objWordDoc.Variables.item["SerialNumber"] .Value = "Here goes Serial Number"
$Ret = $objWordDoc.Fields.Update()
$Ret = $objWordApp.Documents(1).SaveAs(@SCRIPTDIR + "\Useless Text.doc")
$Ret = $objWordApp.quit()