I spent a couple of hours trying to figure out how to get line numbers on pages to restart in every section. Here is the code I used, before and after the fix.
rng is a Word.Range
The issue wasn't the code. The problem was I had a table that started each section. When I inserted a paragraph before the table the code worked.Code:wdSect = Doc.Sections(Doc.Sections.Count) With wdSect.PageSetup.LineNumbering .Active = CInt(True) .StartingNumber = 1 .CountBy = 1 .RestartMode = Interop.Word.WdNumberingRule.wdRestartSection End With rng.InsertBreak(Interop.Word.WdBreakType.wdSectionBreakNextPage) 'SECTION BREAK
I suspect there are other 'specials' at the start of a section that might cause the same issue.
The fix was adding this to the beginning of each section, before the table.
I wanted to post this because I did not find an answer online. Hopefully this answer helps.Code:rng.InsertParagraphAfter() rng.Font.Size = 4


Reply With Quote