none
footer macro RRS feed

  • Question

  • How do you create a macro to select the 1st line in a word documnet and add the text to the footer on every page?
    Thursday, March 17, 2011 3:09 PM

Answers

  • I got it to work doing this. Thank you Hans. :)

        Selection.HomeKey Unit:=wdStory
        Selection.EndKey Unit:=wdLine, Extend:=True
        ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = _
            Selection.Text

        Selection.HomeKey Unit:=wdStory
        Selection.EndKey Unit:=wdLine, Extend:=wdExtend
        Selection.Delete Unit:=wdCharacter, Count:=1

    • Marked as answer by Tessa75 Thursday, March 17, 2011 4:34 PM
    Thursday, March 17, 2011 4:34 PM

All replies

  • Does this do what you want? (Test on a copy of your document)

    Sub SetFooter()
        Selection.HomeKey Unit:=wdStory
        Selection.EndKey Unit:=wdLine, Extend:=True
        ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = _
            Selection.Text
    End Sub


    Regards, Hans Vogelaar
    Thursday, March 17, 2011 3:48 PM
  • Hi thank you for replying! Can you make it cut the 1st line in a word document instead of copy?
    Thursday, March 17, 2011 4:24 PM
  • I got it to work doing this. Thank you Hans. :)

        Selection.HomeKey Unit:=wdStory
        Selection.EndKey Unit:=wdLine, Extend:=True
        ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Text = _
            Selection.Text

        Selection.HomeKey Unit:=wdStory
        Selection.EndKey Unit:=wdLine, Extend:=wdExtend
        Selection.Delete Unit:=wdCharacter, Count:=1

    • Marked as answer by Tessa75 Thursday, March 17, 2011 4:34 PM
    Thursday, March 17, 2011 4:34 PM