autotext in headerfooter – VBA

S

sugarboyrosnerd

Using: Word 2000

This is my first post, but I've been reading your pages all year and find
them enormously useful. I am a beginning VBA programmer.

I am creating a suite of automated templates for my company. I have a macro
that deletes all content within all headers and footers in the active
document.

Now I want to create a macro that inserts autotext into all headers and
footers. The autotext is a series of docvariable fields stored in a global
template. I don't know where to begin. Could you please help?

best wishes from Western Canada,
sugarboyrosnerd
 
D

Doug Robbins - Word MVP

I would recommend that you do not use VBA to set up the headers and footers
in documents created from templates. It is much easier to just create the
template with the headers and footers already in them.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
S

sugarboyrosnerd

I agree Doug. In fact, my templates already contain the required header and
footer fields, as you recommended in your last post.
Perhaps I should explain why I want to create a macro that will insert
autotext in headers and footers. I'm concerned that users will delete
existing header/footer docvariable fields, which will generate an error
whenever the user tries to update the docvariable fields.
My logic is this – by deleting all header and footer content and then
replacing all header and footer content with autotext (that contains
docvariable fields), I'll have a quick and automatic way to correct all
headers and footers – no matter how badly the user messes up the
header/footer content.
Does this make sense to you?
Thank you for your time and advice.
best wishes from Western Canada,
sugarboyrosnerd
 
D

Doug Robbins - Word MVP

While the deletion of Docvariable field will result in the desired result
not being achieved, it should not cause any error message to appear.

Maybe more appropriate for you to see the article "How can I prevent users
from editing the header of a document in Word 2000 or higher?" at:

http://www.word.mvps.org/FAQs/Customization/ProtectWord2000PlusHeader.htm

or, "How can I prevent users from editing the header of a Word 97 document?"
at:

http://www.word.mvps.org/FAQs/Customization/ProtectWord97Header.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
S

sugarboyrosnerd

Absolutely spectacular Doug! I didn't think this was even possible.
This works and is a far better solution than the one I proposed.
Thank you, thank you, thank you.

best wishes from Western Canada,
sugarboyrosnerd
 
R

Russ

Sugarboyrosnerd,
Using: Word 2000

This is my first post, but I've been reading your pages all year and find
them enormously useful. I am a beginning VBA programmer. Microsoft.public.word.vba.beginners

I am creating a suite of automated templates for my company. I have a macro
that deletes all content within all headers and footers in the active
document.

Now I want to create a macro that inserts autotext into all headers and
footers. The autotext is a series of docvariable fields stored in a global
template. I don't know where to begin. Could you please help?
Have you tried recording a macro while manually going through the operations
required? Then look at the code produced. That's where you can begin.
Afterwards, if you have more specific questions, you can ask in another
message thread.
 

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