footer.Shapes.AddTextbox

S

Senad Isanovic

Use this code to add en textbox on the first page (Footer) in the document.
Now I need to att the textbox to all pages in the doc om the same position.
The trouble starts with big documents with several sections. In that case I
need to loop through all sections before the doc open and update the content
of the textbox with the latest doc no and ver no. sometimes that takes to
long time which is not a good option. My question now is how I can add a
textbox or something similar that contains doc no and ver no to all pages
and sections in the doc but without taking so long time? Thanks!





Set myrange =
ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage).Range
Set myfooter =
ActiveDocument.Sections(1).Footers(wdHeaderFooterFirstPage)

myrange.Collapse WdCollapseDirection.wdCollapseEnd

AddTxtbox sRef, myrange, myfooter, top




Sub AddTxtbox(sRef As String, myrange As Range, footer As HeaderFooter, top
As Double)
On Error GoTo errHandler
Dim mytxtbox As Shape
Dim havetextbox As Boolean

RemoveTextboxesSection1

Set mytxtbox = footer.Shapes.AddTextbox(msoTextOrientationUpward, 0, 0,
12, 70, myrange)

With mytxtbox
.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
.Left = InchesToPoints(0.25)
.RelativeVerticalPosition = wdRelativeVerticalPositionPage
.top = InchesToPoints(top)
.Line.Visible = msoFalse
.TextFrame.MarginLeft = 1
.TextFrame.MarginRight = 1
.TextFrame.MarginBottom = 1
.TextFrame.MarginTop = 1
.TextFrame.TextRange.Font.Name = "Arial"
.TextFrame.TextRange.Font.Size = 6
.TextFrame.TextRange.Text = sRef

End With

Set myrange = Nothing
Set mytxtbox = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top