PDA

View Full Version : Updating MS Word document header and Footer using a macro



chamdan
04-24-2012, 05:45 PM
Hi,

I am looking at having either a macro or a function that can do work for me.
I want based on certain criteria to change the Header content and place today's date and then update the footer with the fullpathname.

I could not figure out how to do it since I am fully new to vb.

Can someone provide me such macro or function?

Regards,

Chuck

fumei
04-24-2012, 07:01 PM
How can we do that if we do not know what the "certain criteria" is, nor what "change the Header content" means? Change to...what? Place today's date where?

Are you going to be doing this a lot? If not, why bother with trying to get code?

But if you want to do this, can you give us some more details about what you want to do?

chamdan
04-24-2012, 07:16 PM
Thanks Fumei for getting back to me.

To answer to your question, yes it will be a one time use, I mean one time because it is for one of my extraction I am doing from MSProject then Excel gets the resulted extraction and puts the data in a word document. I have achieved all the parts even writing into word the extracted data. My only concern where I am failing to make work is updating the header of the word document.

The criteria I am talking about is as follow:
I have inputbox where the user will select the group number from the WBS (Work Breakdown Structure) so the header should say:

Extracted issues for the WBS Group [xxx] "where xxx is the WBS".
So The header should look like:

April 24, 2012 - Extracted issues related to the WBS Group [xxx]

If the answer to the inpubox is nothing then the header should say:

April 24, 2012 - Extraction of all issues related to the Schedule.

and for the footer that is not a problem since it is always the same.

fullPathname of the file Page x of nn

Hope this can help.

Regards,

Chuck

fumei
04-24-2012, 08:42 PM
d for the footer that is not a problem since it is always the same.

fullPathname of the file Page x of nn
Then use a template. Done.

As for the header, is there anything there to start with? Are you really changing things, or are you adding things?

chamdan
04-24-2012, 09:36 PM
Fumei,

Yes, I am using the regular header template that is available in msword 2007. The header has like calendar where you pick the date and beside the text field named Title. So My objective is to overwrite the update the title and update the date as per today's date.
I believe it is called the Austere Even page. When you try to insert a header you may select one of the header type and the one I am using is the one that has red calendar and title beside.
Is it possible to overwrite the title instead of writing it each time based on the extraction we are doing.

There must be a very simple way to apply the update. I am not a programmer but learning vba from the forums. So please bear with me.

Thanks in advance for your help Fumei.

Regards and good night it is almost 12:30 Am here in Ottawa. I am falling asleep.

Chuck

fumei
04-24-2012, 09:52 PM
I believe it is called the Austere Even page. When you try to insert a header you may select one of the header type and the one I am using is the one that has red calendar and title beside.
Huh? Are you saying there are controls in the header you select from?????

Say hi to Ottawa for me (my hometown).

chamdan
04-25-2012, 03:08 PM
Hi Fumei,

Ottawa says hi to you too. you must be missing your home town. Yep! Ottawa is nice.

Anyway, just to get back to where I left yesterday, I have come up with a different approach due to the complexity of that matter. As I said, I am not a programmer and had to find a another way, which is instead of updating the header I have managed to insert a title at the beginning of my word document and therefore would not go any further but would like to thank you for trying to help.

Cheers!

Chuck