Hi Guys,

Trying to automate some things in Word and I'm not having any luck yet. What I would like to do is add an image and set the text wrapping to Square. I have seen some posts about InLine shapes not supporting text wrapping options but I did not find a definitive answer on that yet. Second thing I tried is recording a macro but text wrapping buttons are disabled when recording a macro.

Did anybody do anything like this? any help would be appreciated because I s*ck at COM scripting. The code below says everything worked fine but text wrapping is still set to InLine.

I'm runnign Word 2010, and kix 4.66.

 Code:
Break on

$objWord = CreateObject("Word.Application")
? @ERROR
? @SERROR

$objDoc = $objWord.Documents.Add()
? @ERROR
? @SERROR

$objSelection = $objWord.Selection
? @ERROR
? @SERROR

$objWord.Visible = True
? @ERROR
? @SERROR

$objShape = $objSelection.InlineShapes.AddPicture("c:\somefolder\image.png")
? @ERROR
? @SERROR

;wdWrapSquare = 0
;wdWrapTight = 1
;wdWrapThrough = 2
;wdWrapNone = 3
;wdWrapTopBottom = 4

$objShape.WrapFormat.Type = 0 ;"wdWrapSquare"
? @ERROR
? @ERROR

$objSelection.TypeText("111")
$objSelection.TypeText(Chr(11))
$objSelection.TypeText("222")
$objSelection.TypeText(Chr(11))
$objSelection.TypeText("333")
$objSelection.TypeText(Chr(11))
$objSelection.TypeText("444")

Sleep 10

;Quit word
$objWord.Quit


Edited by Mart (2016-10-17 12:07 PM)
Edit Reason: fixed typo in the code
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.