# Finalbuilder server - MS Word com object

**URL:** <https://www.finalbuilder.com/forums/t/finalbuilder-server-ms-word-com-object/3381>\
**Category:** Bugs\
**Created:** [August 8, 2011, 11:47am UTC](https://www.finalbuilder.com/forums/t/finalbuilder-server-ms-word-com-object/3381 "2011-08-08T11:47:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)\
**Post date:** [August 8, 2011, 11:47am UTC](https://www.finalbuilder.com/forums/t/finalbuilder-server-ms-word-com-object/3381/1 "2011-08-08T11:47:45Z")

</div>

Hi,

I have a small project that opens a MS&nbsp;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:

&nbsp;

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

&nbsp;

At line:7 char:12

&nbsp;

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

&nbsp;

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

&nbsp;

&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : InvokeMethodOnNull

&nbsp;

  

&nbsp;

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

&nbsp;

At line:8 char:11

&nbsp;

+ $doc.Close \<\<\<\< ()

&nbsp;

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

&nbsp;&nbsp;&nbsp; + FullyQualifiedErrorId : InvokeMethodOnNull

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

Thx

&nbsp;

---

<div class="post-metadata">

**Author:** ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)\
**Post date:** [August 8, 2011, 3:17am UTC](https://www.finalbuilder.com/forums/t/finalbuilder-server-ms-word-com-object/3381/2 "2011-08-08T03:17:17Z")

</div>

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](http://forums.asp.net/t/1328690.aspx/1)

---

<div class="post-metadata">

**Author:** ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)\
**Post date:** [August 9, 2011, 2:28am UTC](https://www.finalbuilder.com/forums/t/finalbuilder-server-ms-word-com-object/3381/3 "2011-08-09T02:28:47Z")

</div>

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