Append Text in MS Word Textbox?

I'm using PowerShell 4.0 to open and edit an MS Word 2013 document, create tables, apply formatting etc then save as. Everything is fine and works okay, but I need to append the text in a Word textbox on the first page and Word treats content inside the box seperately to the main document.

I thought it would be something like:

$doc.Shapes(1).TextFrame.TextRange.Text+= "test"

But apparently [Microsoft.Office.Interop.Word.DocumentClass] does not contain a method named 'Shapes'.

Any ideas? Thanks in advance

Adam

August 19th, 2015 12:16pm

$doc.Shapes.Item.(1).TextFrame.TextRange.Text+= "test"
Free Windows Admin Tool Kit Click here and download it now
August 19th, 2015 12:34pm

The property 'value' cannot be found on this object. Verify that the property exists and can be set.

Thanks for the reply jrv - I'll see if I can work with it tomorrow.

August 19th, 2015 12:38pm

$doc.Shapes.Item(1).TextFrame.TextRange.Text+= "test"
Free Windows Admin Tool Kit Click here and download it now
August 19th, 2015 4:29pm

I get the error:

The property 'text' cannot be found on this object. Verify that the property exists and can be set.

I'll keep looking at it and see where I get but any other ideas are appreciated.
Thanks


  • Edited by Adam-M 22 hours 45 minutes ago
August 19th, 2015 4:33pm

Turns out jrv was most of the way there. The syntax is:

$doc.Shapes.Item(1).TextFrame.TextRange.Text+= "test"

So for reference that's no dot between the item and the item name

Thanks for the assist

Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 4:48am

Sorry - typo - I fixed it.

August 20th, 2015 6:20am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics