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 )
Jean-Guy Marcil - 27 Apr 2007 17:48 GMT
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
[quoted text clipped - 34 lines]
> 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?

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org