anchoring a textbox in a footer

L

Liz

We have a macro that inserts a textbox with the docID in all the
footers of a document. When I use a certain template, after I add a
page break, the doc id appears at the top of the pages of the document
with the primary footer. I don't think it's related to the template
itself because I've heard users complain of the problem in other
circumstances. It's only with template I can replicate it. My
suspicion is that it's an anchoring issue. The code has the textbox
anchored to the first character in the footer. I tried to anchor it
to the first paragraph instead but when I try to set the range, I get
a mismatch error. Can anybody tell me what I'm doing wrong? (code is
below)

thanks.


Dim objSEC As Word.Section
Dim objFTR As Word.HeaderFooter
Dim objTBL As Word.Table
Dim objRNG As Word.Range
Dim oShape As Word.Shape
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")


For Each objSEC In ActiveDocument.Sections
For Each objFTR In objSEC.Footers

If objFTR.LinkToPrevious = False Or objFTR.Index =
wdHeaderFooterFirstPage Then

If objFTR.Exists = True Then

<snip>

Set objRNG = objFTR.Range.Paragraphs(1)
Set tbox =
objFTR.Shapes.AddTextbox(msoTextOrientationHorizontal,
InchesToPoints(0.25), _
0, InchesToPoints(1.2), InchesToPoints(0.4),
objRNG )
 
J

Jean-Guy Marcil

Liz was telling us:
Liz nous racontait que :
We have a macro that inserts a textbox with the docID in all the
footers of a document. When I use a certain template, after I add a
page break, the doc id appears at the top of the pages of the document
with the primary footer. I don't think it's related to the template
itself because I've heard users complain of the problem in other
circumstances. It's only with template I can replicate it. My
suspicion is that it's an anchoring issue. The code has the textbox
anchored to the first character in the footer. I tried to anchor it
to the first paragraph instead but when I try to set the range, I get
a mismatch error. Can anybody tell me what I'm doing wrong? (code is
below)

thanks.


Dim objSEC As Word.Section
Dim objFTR As Word.HeaderFooter
Dim objTBL As Word.Table
Dim objRNG As Word.Range
Dim oShape As Word.Shape
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")


For Each objSEC In ActiveDocument.Sections
For Each objFTR In objSEC.Footers

If objFTR.LinkToPrevious = False Or objFTR.Index =
wdHeaderFooterFirstPage Then

If objFTR.Exists = True Then

<snip>

Set objRNG = objFTR.Range.Paragraphs(1)
Set tbox =
objFTR.Shapes.AddTextbox(msoTextOrientationHorizontal,
InchesToPoints(0.25), _
0, InchesToPoints(1.2), InchesToPoints(0.4),
objRNG )

Set objRNG = objFTR.Range.Paragraphs(1)
should be
Set objRNG = objFTR.Range.Paragraphs(1).Range

Also, you declare oShape, but you use tBox?

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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