Finalbuilder server - MS Word com object

Hi,

I have a small project that opens a MS Word document (.docx) and saves it again in pdf format with the help of this PowerShell script:

$word = new-object -ComObject "word.application"
$doc = $word.documents.open( "C:\temp\test.docx" )
$saveaspath = [ref] "C:\temp\test.pdf"
$formatPDF = [ref] 17
$doc.SaveAs($saveaspath,$formatPDF)
$doc.Close()

When i run this project via the FinalBuilder IDE all works fine, but when i run this project via the finalbuilder server website with the same user credentials i end up with the following error:

 

You cannot call a method on a null-valued expression.

 

At line:7 char:12

 

+ $doc.SaveAs <<<< ($saveaspath,$formatPDF)

 

    + CategoryInfo          : InvalidOperation: (SaveAs:String) [], RuntimeException

 

    + FullyQualifiedErrorId : InvokeMethodOnNull

 


 

You cannot call a method on a null-valued expression.

 

At line:8 char:11

 

+ $doc.Close <<<< ()

 

    + CategoryInfo          : InvalidOperation: (Close:String) [], RuntimeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

Could it be that IIS 7.5 is not able to create a MS Word com object or something like that ?
FYI: I'am running the application pool of FBServer in 32bit mode.

Thx

 

I suspect this is something to do with DCOM (ugly stuff). I found this possible work around with a quick google : http://forums.asp.net/t/1328690.aspx/1

Yep it worked !
Thank you for the tip # close application wrapper
$oApp.Quit([ref]$false)
$oApp = $null