none
Setting header margins in Word

    Question

  • Hi!

    I have created a header with a table.  I need to move the table to the right just a bit, but I cannot seem to find any code on how to set a margin with the API.  (I really prefer not to mess with the XML.)

    How can I modify my margins (or somehow move my header table to the right).

    Thanks in Advance!
    Rich
    Tuesday, March 16, 2010 6:34 PM

Answers

  • Hello Rich,

    Welcome to MSDN forums!

    I assuming you are working on Word 2007, and when you edit your header with a table, you could run following script to move the table:

     Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=68.4, RulerStyle:= _
            wdAdjustNone

    If you have any trouble to cast this code to VB.Net or C# please feel free to follow up, and if I'm misunderstanding your question please kindly get back to me with more details on your scenario.

    Looking forward to your comments.

    Thanks.
     

    Tim Li

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by RichB2005 Thursday, March 18, 2010 12:27 PM
    Wednesday, March 17, 2010 6:06 AM
  • I found it! 

    table.Rows.RelativeVerticalPosition =

    WdRelativeVerticalPosition.wdRelativeVerticalPositionPage;

    table.Rows.VerticalPosition = 15;

    Thanks!

    • Marked as answer by RichB2005 Thursday, March 18, 2010 12:22 PM
    Thursday, March 18, 2010 12:22 PM

All replies

  • Hello Rich,

    Welcome to MSDN forums!

    I assuming you are working on Word 2007, and when you edit your header with a table, you could run following script to move the table:

     Selection.Tables(1).Rows.SetLeftIndent LeftIndent:=68.4, RulerStyle:= _
            wdAdjustNone

    If you have any trouble to cast this code to VB.Net or C# please feel free to follow up, and if I'm misunderstanding your question please kindly get back to me with more details on your scenario.

    Looking forward to your comments.

    Thanks.
     

    Tim Li

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by RichB2005 Thursday, March 18, 2010 12:27 PM
    Wednesday, March 17, 2010 6:06 AM
  • Hi!

    Thank you!  This is what I am looking for.  Now, however, the customer has another requirement (don't they always?).  :-)

    There is a small gap between the bottom of my header and the top of the main body.  Is there a way for me to move the header down (or the body up) so that the bottom of the header touches the top of the body?

    Thanks for your help!

    Rich
    Thursday, March 18, 2010 11:36 AM
  • I found it! 

    table.Rows.RelativeVerticalPosition =

    WdRelativeVerticalPosition.wdRelativeVerticalPositionPage;

    table.Rows.VerticalPosition = 15;

    Thanks!

    • Marked as answer by RichB2005 Thursday, March 18, 2010 12:22 PM
    Thursday, March 18, 2010 12:22 PM