(Edited by jscher2000 on 31-Jul-03 11:48. Added [ pre ] and [ /pre ] tags arround the code to preserve the indenting.)
I’m using the below to add footers to word documents. I’ve run into an issue where it won’t update all sections of the documents footers. Attached is a sample of the document where this does not work. If I run the code it will only update the first page(section). Then I have to select the second section and re-run.
I want to run once and have it update the document.
***CODE*****************************
Application.ScreenUpdating = False varName = "Name" varPhone = "Phone" varcount = ActiveDocument.Sections.Count ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter Selection.TypeText Text:=varName & Chr(10) & varPhone & Chr(10) & Date & Chr(10) Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "FILENAME", PreserveFormatting:=True Selection.TypeText Text:=vbTab & vbTab Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldPage Selection.TypeParagraph Selection.WholeStory With Selection.Font .Name = "Times New Roman" .Size = 8 .Bold = False .Italic = False .Underline = wdUnderlineNone .UnderlineColor = wdColorAutomatic .StrikeThrough = False .DoubleStrikeThrough = False .Outline = False .Emboss = False .Shadow = False .Hidden = False .SmallCaps = False .AllCaps = False .Color = wdColorAutomatic .Engrave = False .Superscript = False .Subscript = False .Spacing = 0 .Scaling = 100 .Position = 0 .Kerning = 0 .Animation = wdAnimationNone End With i = 2 If varcount > 1 Then Do Until i > varcount With ActiveDocument.Sections(i).Footers(wdHeaderFooterPrimary) ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter Selection.TypeText Text:=varName & Chr(10) & varPhone & Chr(10) & Date & Chr(10) Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "FILENAME", PreserveFormatting:=True Selection.TypeText Text:=vbTab & vbTab Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldPage Selection.TypeParagraph Selection.WholeStory With Selection.Font .Name = "Times New Roman" .Size = 8 .Bold = False .Italic = False .Underline = wdUnderlineNone .UnderlineColor = wdColorAutomatic .StrikeThrough = False .DoubleStrikeThrough = False .Outline = False .Emboss = False .Shadow = False .Hidden = False .SmallCaps = False .AllCaps = False .Color = wdColorAutomatic .Engrave = False .Superscript = False .Subscript = False .Spacing = 0 .Scaling = 100 .Position = 0 .Kerning = 0 .Animation = wdAnimationNone End With With Selection.HeaderFooter.PageNumbers .NumberStyle = wdPageNumberStyleArabic .HeadingLevelForChapter = 0 .IncludeChapterNumber = False .ChapterPageSeparator = wdSeparatorHyphen .RestartNumberingAtSection = False .StartingNumber = 0 End With End With i = i + 1 Loop End If ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument 'Turn on Screen Updating Application.ScreenUpdating = True
***CODE*****************************
Thank you very much!!