1

Is there a way to insert a horizontal line within a Power Shell generated MS Word document? If so, what is the code needed to do this?

1 Answer 1

2
$Document = "c:\temp\tralala.doc" #Must exist

$Word = New-Object -Com Word.Application
$Word.Visible = $true
$ExistingDoc = $Word.Documents.Open($Document)
$ExistingDoc.Shapes.AddLine(0,0,1000,1000)
$ExistingDoc.Save()
$Word.Quit()

WordDocument.Shapes.AddLine(BeginX, BeginY, EndX, EndY, Anchor) is the call drawing the line where BeginX, BeginY are the position (in points) of the line's starting point, relative to the anchor. EndX, EndY are the position (in points) of the line's end point, relative to the anchor. If anchor is omitted, the line is positioned relative to the top and left edges of the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.