Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I Create Word Headers in VBA?

Status
Not open for further replies.

kaz8896

Programmer
Dec 20, 2001
9
0
0
US
Hi Everybody,

I'm writing several macros in VBA that insert different documents in each one to form a template for our letters. I'm trying to find out how to create headers programmably through VBA. The reason I need to do it this way is because, when the user clicks the button on the toolbar that has the macro linked to it, they are prompted to enter a number. Weather it be a quote number, po number, job number and so on. I store the number in a string variable and I need to display it in the header of every page along with the page number under it. If anyone knows of a way to do this through VBA I would greatly appriciate it if you could post some code that would help me. Thank you very much for your time.

Sincerely,
Derek
kaz5456@aol.com
 
dear derek,

in the headers you enter the following field function (in German it is Feldfunktion) via insert field

DOCVARIABLE "hugo" \* MERGEFORMAT


you can add docvariables via
ThisDocument.Variables.Add "hugo"

and you can assign values to it via

ThisDocument.Variables.Item("hugo") = "upps"



HTH

regards Astrid
 
Dear Astrid


I tried the code samples that you gave me and I could not get them to work. If you have the time could you please check if there was possible a syntax error with the code you gave me. If you can find a problem I would be very greatful if you could post the revised code. If not, well then I guess I'm S.O.L. Thank you very much for help.

Sincerely,
Derek
 
Dear Derek,

I created the code via copy and paste so I am very sure it works.

Please tell me what your problems look like?

regards Astrid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top