Consulting

Results 1 to 8 of 8

Thread: Solved: Reset tab in footers

  1. #1
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location

    Solved: Reset tab in footers

    I need to reset a tab in all footers in the document by macro. How do I change a 6.53" right tab to a 6.28" right tab?

  2. #2
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Try recording a macro to reset Tabs.

    Apply it to all footers using a Footer object.

  3. #3
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    Among other things, I tried the following, but it doesn't change the margins in every section. What am I doing wrong?

    [VBA]Sub A4LeftRightMargins()

    Dim intSecCount As Integer
    Dim intSection As Integer
    intSecCount = ActiveDocument.Sections.Count
    For intSection = 1 To intSecCount
    With ActiveDocument.Sections(intSection)
    ' Reset margins
    With Selection.PageSetup
    .LeftMargin = InchesToPoints(0.89)
    .RightMargin = InchesToPoints(0.89)
    End With
    End With
    Next intSection
    End Sub
    [/VBA]

  4. #4
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    Oops! I attached the wrong code -- the code I attached above is to reset the margins (another attempt to solve the problem). Actually, if I can get that code to work correctly, I won't have to reset the tabs.

  5. #5
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    [vba]

    Dim oHF As HeaderFooter
    Dim oSec As Section
    For Each oSec In ActiveDocument.Sections
    For Each oHF In oSec.Headers
    With oHF.Range.ParagraphFormat.TabStops
    .ClearAll
    .Add Position:=CentimetersToPoints(6.28), _
    Alignment:=wdAlignTabLeft, _
    Leader:=wdTabLeaderSpaces
    End With
    Next
    Next


    [/vba]

  6. #6
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    It didn't work -- the tab didn't change in any of the footers.

  7. #7
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Works for me. Demo attached.

    Scroll down so you can see the footer. There is text "Start", and it is at the existing tabstop of 8.32.

    Click "Change Footer tab" on the top toolbar. It fires the code, changing the tabstop to 6.28. You can see the text "Start" move to the left - from 8.32 to 6.28.

  8. #8
    VBAX Mentor clhare's Avatar
    Joined
    Mar 2005
    Posts
    470
    Location
    I must have had it in the wrong place in the code. I moved it and it works great! Thank you so much for your help!

Posting Permissions

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