MS Word - Bookmarks in Headers not updating correctly

RichCowell

Board Regular
Joined
Dec 5, 2013
Messages
121
Office Version
  1. 365
Platform
  1. Windows
Hi all,
I've got a document I'm using as a template with several sections.

Page 1 is a title page with the:
  1. Document Title
  2. Published Date
  3. Updated Date
Those three items are all bookmarks.

Those three items are also included in the header of each page.

When I'm ready to finalise the file and update everything with F9, only the first page of each section updates - although the other pages show as having updated, when I exit the Header & Footer, the subsequent pages in each section revert back to the original text, and only the first page in each section has updated.

I've seen elsewhere online that it may be resolved with the following code:
VBA Code:
foreach (Aspose.Words.Bookmark bookMark in
doc.Range.Bookmarks)
{
bookMark.Text = “New Text”;

}
Which I've added but it doesn't seem to make any difference.

Is anyone able to point me in the right direction?

(Also - if anyone knows of a way of updating the headers in all sections with one command rather than having to do each section individually, I'd be eternally grateful too!)

Thanks,

Rick
 
It does work there - provided the code is written to do so.

A simple workaround would be to.
1 Apply unique Style names to each of your Document Title, Published Date, & Updated Date ranges in the document body, (e.g. Title, Published , & Updated)
2. Replace the 'REF' in the cross-reference fields with 'STYLEREF' and delete \* MERGEFORMAT from the fields.
With those changes, the fields in the header will update any time the text in the Title, Published , & Updated Style ranges is updated.

Awesome, thank you! I've never used STYLEREF before - that's going to be really helpful going forwards!
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,223,893
Messages
6,175,249
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top