Add footer to word document using VBscript

G

guido

Is it possible to programmatically add (using vbscript) a footer & toc
to a word document once it has been created and saved? Can anyone give
me some example code please?
(also posted this on microsoft.public.scripting.vbscript)
 
C

Cindy M -WordMVP-

Hi Guido,
Is it possible to programmatically add (using vbscript) a footer & toc
to a word document once it has been created and saved? Can anyone give
me some example code please?
(also posted this on microsoft.public.scripting.vbscript)
Did you get any help on this? Yes, it should be possible. I can't show
you the vbscript, but I would know the VBA, which ought to get you going
if you have any experience automating Word, at all.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
G

guido

HI - sorry it's taken a while to get back to you! Any example vb code
would be really useful.
 
C

Cindy M -WordMVP-

Hi Guido,

<<Is it possible to programmatically add (using vbscript) a
footer & toc to a word document once it has been created
and saved? >>
Any example vb code
would be really useful.
OK, assuming I've assigned the opened document to the
variable doc:

Dim rng as Word.Range

Set rng = _
doc.Sections(1).Footers(wdHeaderFooterPrimary).Range
rng.Text = "left margin text" & vbTAB & _
"center text" & vbTAB & "right margin text"
rng.Style = wdStyleFooter '-33

Set rng = doc.Range
'Start of doc
rng.Collapse
doc.TablesOfContents.Add rng


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 

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