View Single Post
 
Old 01-10-2014, 05:00 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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 can't see why that would occur. the following works for me:
Code:
Sub Demo()
Dim i As Long, Rng As Range, Shp As Shape
Dim iStart As Long, StrPfx As String, StrSig As String
With ActiveDocument
  StrPfx = InputBox("What is the Ref Prefix?")
  StrSig = InputBox("Who's Signature?")
  iStart = CLng(InputBox("What is the Starting #?"))
  For i = 1 To .ComputeStatistics(wdStatisticPages)
    Set Rng = .GoTo(What:=wdGoToPage, Name:=i)
    Set Rng = Rng.GoTo(What:=wdGoToBookmark, Name:="\page")
    Rng.Collapse wdCollapseStart
    Set Shp = .Shapes.AddTextbox(Orientation:=msoTextOrientationHorizontal, _
      Left:=0, Top:=0, Width:=100, Height:=40, Anchor:=Rng)
    With Shp
      .RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
      .Left = wdShapeRight
      .RelativeVerticalPosition = wdRelativeVerticalPositionMargin
      .Top = wdShapeTop
      .Fill.Visible = False
      With .TextFrame.TextRange
        .ParagraphFormat.SpaceAfter = 0
        .ParagraphFormat.SpaceBefore = 0
        .Font.Bold = True
        .Font.Size = 8
        .Font.ColorIndex = wdBlue
        .Text = "Ref. No.: " & StrPfx & (i + iStart - 1) & vbCr & StrSig & " " & Format(Now, "D MMM YYYY")
        .Paragraphs.First.Range.Font.ColorIndex = wdRed
      End With
    End With
  Next
End With
End Sub
Note that I've made a few extra changes because I'm not using a userform and to control the textbox formatting, but that doesn't affect the underlying process.

PS: Please don't quote entire posts in your reply - only quote what's actually necessary.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote