Results 1 to 4 of 4

Thread: Hiding Footers

  1. #1
    New Lounger
    Join Date
    Feb 2001
    Location
    Washington, District Of Columbia, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hiding Footers

    I am creating a form in Word2000 and want to hide (not display or print) certain sections (including their footers) that are not used. I use the following statements where a = 2
    .StoryRanges(wdMainTextStory).Sections(a).Range.Fo nt.Hidden = True
    .Sections(a).Headers(wdHeaderFooterPrimary).Range. Font.Hidden = True
    It hides the main text, but looses the sequencing with the footers. That is, if I hide the body and footer of section 2, then it shows section 1 with the section 1 footer and then section 3 with the section 2 footer.
    Any ideas of how to fix or work around this?

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Hiding Footers

    Is the section break being hidden as well as the text within it?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    New Lounger
    Join Date
    Feb 2001
    Location
    Washington, District Of Columbia, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding Footers

    Yes, the section break (Next Page) is being hidden. As you know, a Word document consists of many storyparts or layers. This is why I try to separately hide the sections in both storyparts. However, VBA seems to allow only very different dot strings for these two layers. Is there some other dot string that I should be using?

  4. #4
    New Lounger
    Join Date
    Feb 2001
    Location
    Washington, District Of Columbia, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hiding Footers

    Just an update for anyone following or referencing this thread. I have tried a workaround by saving the footer text into document variables to save with the document only after I have made changes. The code for that is rather simple:

    <pre>N = ActiveDocument.Variables.Count
    i = 0 'We must delete all old values so the Add does not fail
    Loop1: 'We use a loop instead of a For to change i as we go along
    i = i + 1 'i is the index into the document variable set
    If i > ActiveDocument.Variables.Count Then GoTo PutIn
    If Left(ActiveDocument.Variables(i).Name, 2) = "Fn" Then 'if we put it in
    ActiveDocument.Variables(i).Delete ' we delete it
    i = i - 1 'One less item, so check this same index again
    End If
    GoTo Loop1

    PutIn:
    ' Now save the existing footnote text as variables
    For i = 1 To N 'For each section,
    'first create variables FnS and Fn for ADD statement
    FnS = "FnS" & Format(i) 'Footnote sect numb => var name
    Fn = ActiveDocment.Sections(i) _
    .Footers(wdHeaderFooterPrimary) _
    .Range.Text 'Footer text to save in doc variable
    ActiveDocument.Variables.Add Name:=FnS, Value:=Fn 'Save it
    Next i
    t = MsgBox(Format(ActiveDocument.Sections.count) & _
    " section footers saved to " _
    & vbCr & ActiveDocument.Name)
    </pre>


    Bringing them back to rebuild the footers is less of a problem since we do not have to worry if they are there or not.

    <pre>j = 2
    For i = 3 To a(0, 0) 'i cycles a control table
    If a(i, 2) Then ' if this footer is visible, we put it as next footer
    j = j + 1
    FnS = "FnS" & Format(i) 'Form variable name holding text
    Activedocument.Sections(j).Footers(wdHeaderFooterP rimary) _
    .Range.Text = .Variables(FnS).Value
    End If
    Next i
    </pre>

    Unfortunately, I am learning more and more about VBA and Word. Now it hides or deletes many of the shapes (a box to frame the page) in the sections that are hidden and unhiding does not get them back. See a later posting entitled

Posting Permissions

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