Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Feb 2006
    Location
    Washington, District Of Columbia
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating a Macro (Word 2003)

    Hi,

    I've created a Macro that will add "Celebrating 40 Years" to the footer. However, I want to make it so that if I run it again it removes it and if I run again it will add it (toggle between on/off). Does anyone know how I can make it do that?

    Thanks in advance [img]/forums/images/smilies/smile.gif[/img]

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating a Macro (Word 2003)

    Welcome to Woody's Lounge!

    It depends a bit on whether your document has multiple sections, and multiple footers (e.g. a different first-page footer) within sections, and whether the footer contains more than just that text. Here is a very simple version:

    Sub ToggleFooter()
    Const strText = "Celebrating 40 Years"
    With ActiveDocument.Sections(1).Footers(wdHeaderFooterP rimary).Range
    If InStr(.Text, strText) > 0 Then
    .Delete
    Else
    .Text = vbTab & strText
    End If
    End With
    End Sub

    It either sets the footer to the "Celebrating 40 Years" text, centered, or clears the footer.

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Creating a Macro (Word 2003)

    An alternative approach might be to create a Custom Document Property called, for example, TagLine. You could include this in all your footers and then change it's value whenever you want. This would have the advantage that you could have it mixed with other text in the footer without too much complexity.

    StuartR

  4. #4
    Lounger
    Join Date
    Feb 2006
    Location
    Washington, District Of Columbia
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a Macro (Word 2003)

    Thanks, so much!!!! That is actually perfect since it is mainly going to be used for a letterhead template. I've just started to use macros so I'm a huge novice but hopefully with a class for the fundamentals and practice I'll pick it up.

  5. #5
    Lounger
    Join Date
    Feb 2006
    Location
    Washington, District Of Columbia
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Creating a Macro (Word 2003)

    Thanks! But seeing how I'm a novice at this I don't think I'll be able to go with that option since I won't even know how to begin [img]/forums/images/smilies/smile.gif[/img]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •