John
John

Reputation: 25333

Insert Horizontal Line in Word Document with Power Shell

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?

Upvotes: 1

Views: 1696

Answers (1)

David Brabant
David Brabant

Reputation: 43499

$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.

Upvotes: 2

Related Questions