none
UnlinkToPrevious reduces the number of lines display on a page RRS feed

  • Question

  • How do I prevent the UnlinkToPrevious feature from reducing the number of lines on a page?  I have a document with two sections. I don't want page numbers or line numbers on the first section which is more than 1 page with footnotes, etc., so I do a UnlinkToPrevious. When I do the UnlinkToPrevious, the page displays one line less of text, pushing it down to the next page. For example, before applying the UnlinkToPrevious, the page shows 23 lines of text (double-spaced). After the UnlinkToPrevious, it shows 22 lines of text. I DO NOT want UnlinkToPrevious to change the number of lines. How to stop that from happening? This is important when comparing documents line by line.

    Post here because I will need to implement to solution using VB macro. This is the code I am currently using

    ActiveDocument.Sections(2).Headers(wdHeaderFooterPrimary).LinkToPrevious = False
    ActiveDocument.Sections(2).Footers(wdHeaderFooterPrimary).LinkToPrevious = False

    Thanks a lot

    Tuesday, May 19, 2015 8:55 PM

Answers

  • After all, deleting page numbers from the footer using vb macro causes the problem. The problem goes away when I manually opened and closed the footer. Or if I right click in the footer, edit, and close it, that resolved it too. So for the macro code, I recorded and use the following:

        ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
        ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

    Friday, May 29, 2015 10:43 PM

All replies

  • Hi Fox

    Every section in a document may have its own headers and footers (as well as margin settings and a few other things). If UnlinkToPrevious is changing the number of lines available on the page, then chances are good that the reason is due to the content of the Header of Footer or the settings for the Header/Footer - where it starts at the top of the page, how tall it is, etc.

    So you need to carefully analyze the header/footer areas after you unlink the sections in order to determine why the one set requires more space than the other.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, May 20, 2015 5:54 PM
    Moderator
  • After all, deleting page numbers from the footer using vb macro causes the problem. The problem goes away when I manually opened and closed the footer. Or if I right click in the footer, edit, and close it, that resolved it too. So for the macro code, I recorded and use the following:

        ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
        ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

    Friday, May 29, 2015 10:43 PM
  • Since you are working with recorded code, I suggest that you post all the lines that the macro recorder created. Maybe that is part of the problem.

    Stefan Blom, Microsoft Word MVP

    Saturday, May 30, 2015 2:29 PM
  • Stepfan,

    I am using a mixture of recorded code and VBA code to accomplish the different tasks (procedures).  I used the code from the following link to delete the page numbers: http://www.java2s.com/Code/VBA-Excel-Access-Word/Word/RemovingPageNumbersfromOneorMoreSectionsofaDocument.htm

    After deleting the page numbers, the page would only display 22 lines.  I realized if I simple open and close the footer things work fine, so I recorded the steps which are

    Sub UnlinkFromPervious()
    ' UnlinkFromPerviousSection Macro

        If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
            ActiveWindow.Panes(2).Close
        End If
        If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
            ActivePane.View.Type = wdOutlineView Then
            ActiveWindow.ActivePane.View.Type = wdPrintView
        End If
        ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
        Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
            LinkToPrevious
        ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    End Sub

    Tuesday, June 2, 2015 4:22 AM
  • The code you have posted affects the current footer. Note that a section can have up to three different footers (and three different headers), if "Different first page" and "Different odd and even" are both selected in the Page Setup dialog box. Each type of footer (or header) must be separately unlinked from its "neighbor" in the preceding section. This may be relevant for the problems you are seeing.

    What do you see if you display nonprinting marks in the document? Are there any blank paragraphs present?


    Stefan Blom, Microsoft Word MVP

    Tuesday, June 2, 2015 9:45 AM
  • Stefan,

    Thanks for the information about the possible number of footers/headers in a section. OddAndEvenPagesHeaderFooter = False and DifferentFirstPageHeaderFooter = False. The display nonprinting marks shows a blank paragraph mark in the main footer, which I deleted using Selection.Delete Unit:=wdCharacter, Count:=1, but it still only work if I manually open and close the footer or use the recorded code.

    Tuesday, June 2, 2015 2:27 PM