Updating a StyleRef field

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Updating a StyleRef field

Post by Rudi »

Hi,

I'm using a StyleRef field multiple times in my document. All is well and working but my question is if there is a better way to update the fields to reflect the repetitive text than by pressing CTRL+A and then F9?

If I were to use a macro, which event could I link it to to update the text immediately after the style text is changed?
IOW not using Document_Open or Close or Save, etc...

PS: I don't want to use controls!!

TX
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78393
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Updating a StyleRef field

Post by HansV »

Microsoft Word does not have an event that occurs when text is edited. You might use the WindowSelectionChange event of the Application object, but that would be overkill since it occurs whenever the user selects text or moves the insertion point, whether text has been changed or not.
I would assign a macro to a custom keyboard shortcut and/or a custom Quick Access Toolbar button.
Best wishes,
Hans

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Updating a StyleRef field

Post by Rudi »

Thanks. I was just hopeful there was something I was missing.
You confirmed my suspicions.

Cheers
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
Jay Freedman
Microsoft MVP
Posts: 1316
Joined: 24 May 2013, 15:33
Location: Warminster, PA

Re: Updating a StyleRef field

Post by Jay Freedman »

Rudi, I'm curious about the reason for objecting to controls. While they aren't compatible with Word 2003 and earlier or with Word Online, and some of them aren't well supported in Mac Word, they do have a lot of good uses.

If you want multiple repetitions of entered text to update immediately, the one-and-only mechanism that does that is a set of content controls that are all mapped to a single XML node. An add-in that makes it easy to set up mapped controls is at https://gregmaxey.com/word_tip_pages/cc ... addin.html.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Updating a StyleRef field

Post by Rudi »

Hi Jay,

TX for your feedback and the link.

I am not objecting against controls; this is a support question on behalf of someone else who started using controls and found snags or limits with them. I don't use controls in Word so i couldn't really provide advice to support continuing to use them. This is where I defaulted to my knowledge of using Bookmarks and Cross referencing, or the REF fields and finally the StyleRef field to repeat text. I finally thought to post here to get advice. I'll pass the link on to the person I'm supporting, but it seems quite technical with an add-in. The person also has not got back to me again since my StyleRef advice, so I'm not sure if they have it resolved or not.

Will keep in touch if necessary....

Cheers
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
Charles Kenyon
5StarLounger
Posts: 609
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Updating a StyleRef field

Post by Charles Kenyon »

Rudi,
For your associate with aversion to Content Controls refer to http://addbalance.com/word/MappedControls.htm.
Unless there is a need to use the document in earlier versions of Word, they are a tremendous tool.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Updating a StyleRef field

Post by Rudi »

TX Charles. :thumbup:
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.