troubleshooting Question

How to add page number to text in footer, using word automation from VC++, MFC??

Avatar of pigeonbr
pigeonbr asked on
System Programming
5 Comments1 Solution1721 ViewsLast Modified:
I'm using VC++ and MFC to make a .doc thru automation. All works ok. But I'm having trouble with headers and footers. I have all the ms word constants added to my project, so I have access to all the pertinent classes.

Here is my question:

How to add a footer with text AND the page number?


This is my code THAT DOES NOT WORK so far:
                  //footer
                  HeadersFooters footers(section1.GetFooters());
                  HeaderFooter footer1(footers.Item(1));
                  
                  footer1.SetLinkToPrevious(TRUE);
                  PageNumbers pageNumber;
                  COleVariant varPageNumber((long)wdAlignPageNumberCenter);
                  pageNumber.Add(varPageNumber,TRUE);
                  Range rangeFooter1(footer1.GetRange());

                  rangeFooter1.SetText("This is the footer for all pages");
Can someone help me sort this out please ?
Thanks!
ASKER CERTIFIED SOLUTION
martynjpearson

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros