VMware Cloud Community
Rsasjol
Contributor
Contributor

Reporting with word docuements

Hi,

My need today is to create a report for a worklow which creates a VM.

My first thought was to create a word document with bookmarks, and use VCO PowerShell plugin to run a script which edit bookmarks values..

I end up with a well-running script on my PowerShell host. But as soon as I try to call it from VCO, I end up with messages llike this

System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.

Script is very light and simple

$Filename = "C:\data\Scripts\Bookmark1.docx"

$Filename = "C:\data\Scripts\Bookmark1.docx"

$Word = New-Object -ComObject Word.Application

$Document = $Word.documents.open($Filename)

$Bookmark = $Document.Bookmarks("Book2").Select()

$Word.Selection.text = "Bookmark is filled"

I've digged up a bit, and it seems that, as soon as VCO hits line 4, it goes boom.

Does anybody had any experience with this ? Can you help me ?

Thanks

0 Kudos
1 Reply
Uridium454
Enthusiast
Enthusiast

Rsasjol, I wonder if you are running into a permissions issue.  UAC does interesting things when trying to pass creds from vRO to PowerShell host.  I would look at your current UAC settings, as well as attempt to perform the task with higher privileges.  The other thought I have is that you can try to use Write-Host $word and $document to verify you are getting values in those variables.  Not sure if this will help, but hopefully gets you poking at other possibilities.

0 Kudos