AutoTextEntries("Page X of Y") does not work in Word 2007

N

Nan

I have an Autotextentry "Page x of y" in my vba script in one of my template
as ‘NormalTemplate.AutoTextEntries("Page X of Y").Insert Where:=Selection.
Range, RichText:=True’,
this works fine in word 2003 but not in 2007, so I changed the script
accordingly to work for 2007 as
Templates(“Building Blocks.dotxâ€).BuildingBlockEntries("Bold Numbers").
Insert Where:=Selection.Range, RichText:=True
Which is working fine in 2007 (offcourse not in 2003). As my clients are
still in a migration process to office 2007 some are still having word 2003.
I need to update the script so that it works for both word 2003 and 2007. I
Had no luck in finding the solution for this, any help is greatly
appreciated

Thanks in advance.
Nan
 
G

Graham Mayor

If you save or copy the autotext entry into your document template (DOT)
then the following should work for either version

If Application.Version = 12 Then
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Page x of
y").Insert _
Where:=Selection.Range, RichText:=True
Else
ActiveDocument.AttachedTemplate.AutoTextEntries("Page x of y").Insert _
Where:=Selection.Range, RichText:=True
End If


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
N

Nan

Hi Graham Mayor,

As you said I copied the autotext entry "Page X of Y" into my document
template(dot), and changed the script to
ActiveDocument.AttachedTemplate.AutoTextEntries("Page x of y").Insert _
Where:=Selection.Range, RichText:=True
It is working fine for both the versions 2003 and 2007.
I didnt used the condition to check the version and BuildingBlockEntries, as
BuildingBlockEntries does't contain the"Page X of Y" autotext entry in 2007.

Thank you very much and let me know your comments whether I am doing right.

Thanks,
Nan
 
G

Graham Mayor

If it works fine, then that's all that matters. However why don't you simply
insert the fields into your document template? The macro would appear to be
superfluous.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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