none
How to create a paragraph programmatically on a word document at a specific vertical postion RRS feed

  • Question

  • How can I create a paragraph on a MS Word document page at a specific vertical position? For example if I'm on page 1 and I want to create a paragraph at the top,middle, bottom (or even being more specific like 20%, 30%, 75%)  of the page's vertical position. 

    selam alazar simachew


    • Edited by Selam Alazar Friday, October 16, 2015 11:49 AM grammar and spelling issues
    Friday, October 16, 2015 11:47 AM

Answers

  • Word does not have the functionality you request, mainly because Word is word processor: it concentrates on text flow. What you want to do is more in the realm of page layout.

    Closest you can get in Word would be to insert a TextBox (the drawing object). A TextBox "floats" on the page, can be positioned with some accuracy and supports text in the main document layer "wrapping" around it.

    The basic code would look something like this, but you'll want to spend some time researching the various properties of the Shape object:

        Dim shp As word.Shape
        
        Set shp = ActiveDocument.shapes.AddTextbox( _
    msoTextOrientationHorizontal, _
    100, 100, 100, 100, Selection.Range) shp.TextFrame.TextRange.Text = "Text in the text box" shp.TopRelative = 50 shp.LeftRelative = 50


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Friday, October 16, 2015 6:22 PM
    Moderator