Positioning Text on a Page (Word 2007 VBA)

L

LA Lawyer

I want to force Word to put some text at at specific horizontal and vertical
position on a page, preferably using inches to specify the location.

How is that done?
 
D

Doug Robbins - Word MVP

Use an { ADVANCE } field to set the vertical position and probably paragraph
indents for the horizontal.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
J

Jay Freedman

I want to force Word to put some text at at specific horizontal and vertical
position on a page, preferably using inches to specify the location.

How is that done?

You can use a text box, a frame, or a table cell, any of which can be
positioned in absolute terms with respect to the paper. Here's an
example using a text box:

Sub x()
' place a text phrase exactly at
' 3.52" from top of paper and
' 2.71" from left edge of paper

Dim oTB As Shape ' a text box

Set oTB = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Left:=0, _
Top:=0, _
Width:=InchesToPoints(3), _
Height:=InchesToPoints(1), _
Anchor:=ActiveDocument.Paragraphs(1).Range)
With oTB
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
.Left = InchesToPoints(2.71)
.Top = InchesToPoints(3.52)
.TextFrame.TextRange.Text = "This is my text"
.TextFrame.MarginTop = 0
.TextFrame.MarginLeft = 0
.Line.Visible = msoFalse
.Fill.Visible = msoFalse
End With
End Sub

A frame might be easier to program, but it's getting late...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top