View Single Post
 
Old 11-27-2025, 01:22 PM
macropod's Avatar
macropod macropod is online now Windows 10 Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I have no idea what toggle buttons you're referring to, so I can't help you with that. Additionally, if all you're doing is inserting a table, you could use code like:
Code:
Sub InsertFooterPage()
Application.ScreenUpdating = False
Dim HdFt As HeaderFooter, Rng As Range, Tbl As Table
For Each HdFt In ActiveDocument.Sections.Last.Footers
  If HdFt.Exists Then
    Set Rng = ActiveDocument.Fields.Add(Range:=HdFt.Range, Type:=wdFieldEmpty, Text:="IF= ", PreserveFormatting:=False).Code
    With Rng
      .Collapse wdCollapseEnd
      Set Tbl = .Tables.Add(.Duplicate, 1, 1)
      Tbl.Cell(1, 1).Range.Text = "Hello World"
      Tbl.Range.Characters.Last.Next.InsertBefore Chr(34)
      Tbl.Range.Characters.First.Previous.InsertBefore Chr(34)
      .End = Tbl.Range.Start - 3
      .Fields.Add Range:=Rng, Type:=wdFieldNumPages, PreserveFormatting:=False
      .End = .End - 2
      .Fields.Add Range:=Rng, Type:=wdFieldPage, PreserveFormatting:=False
    End With
  End If
Next
Application.ScreenUpdating = True
End Sub
or even:
Code:
Sub InsertFooterPage()
Application.ScreenUpdating = False
Dim HdFt As HeaderFooter, Rng As Range, Tbl As Table
For Each HdFt In ActiveDocument.Sections.Last.Footers
  If HdFt.Exists Then
    Set Rng = ActiveDocument.Fields.Add(Range:=HdFt.Range, Type:=wdFieldEmpty, Text:="IF=  """"", PreserveFormatting:=False).Code
    With Rng
      .Collapse wdCollapseEnd
      .End = .End - 2
      Set Tbl = .Tables.Add(.Duplicate, 1, 1)
      Tbl.Cell(1, 1).Range.Text = "Hello World"
      .End = Tbl.Range.Start - 3
      .Fields.Add Range:=Rng, Type:=wdFieldNumPages, PreserveFormatting:=False
      .End = .End - 2
      .Fields.Add Range:=Rng, Type:=wdFieldPage, PreserveFormatting:=False
    End With
  End If
Next
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote