PDA

View Full Version : How to vertically align the text in a textframe in Word 2003.



stranno
08-08-2013, 04:02 AM
Hi Friends,
I have been searching on the internet for hours, but i can't figure out how to vertically align a text in a textframe (not textframe2)

This is a part of my code:

Set sh = ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 184, 50, 192, 90)

With sh.TextFrame
.TextRange.Text = "Even geduld aub..."
.TextRange.ParagraphFormat.Alignment = wdAlignParagraphCenter
.MarginTop = 30
end with

I would like ".margin = 30" to be replaced by something like ".TextRange.ParagraphFormat.Vertical Alignment = wdAlignParagraphCenter",
but I don't see how.
Does anyone know how to do this?

The provided code should (also) be able to run in Word 2003

Thanks in advance
Stranno

Doug Robbins
08-08-2013, 11:42 PM
While it is possible to set the text alignment to Middle via the Drawing Tools>Format facility, that feature does not appear to be exposed to the VBA environment and therefore, I think that the best that you can do is use:


Dim sh As Shape
Set sh = ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 184, 50, 192, 90)
With sh.TextFrame
.TextRange.Text = "Even geduld aub..."
.TextRange.ParagraphFormat.Alignment = wdAlignParagraphCenter
With .TextRange.Paragraphs(1)
.SpaceBefore = (90 - .LineSpacing) / 2
End With
End With

stranno
08-09-2013, 02:04 AM
To me this is a very acceptable workaround. Thanks again Doug.