Inserting File into Word Document


using powershell, i'm trying embed zip file word document embedded file displayed icon.

so far, have been able insert verbiage of text file using following code...

---------------------------------------------------------

$objword = new-object -comobject word.application
$objword.visible = $false
$objdoc = $objword.documents.open('c:\test\example.doc')
$selection = $objword.selection 

$objrange = $objdoc.bookmarks.item("txtinsertfile").range
$objdoc.bookmarks.add("newbookmark",$objrange)
$bookmark = $objdoc.bookmarks._newenum | ?{$_.name -eq "newbookmark"}
$bookmark.range.insertfile("c:\test\text.txt")

---------------------------------------------------------

possibly shouldn't using insertfile?  there option?

thanks help!


hi littlemissmagic,

i have not found exact script, maybe can try inlineshapes.addoleobject method.

reference from:

embed file word document

i hope helps.



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file