retaining PART of a character style over a Paragraph style.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

retaining PART of a character style over a Paragraph style.

Post by ChrisGreaves »

I did an Advanced Search and read some topics.

Like st3333ve "Applying a style causes loss of character formats! Why?" I generally use VBA code to apply styles, so an enhancement to my code is a hurdle, but not an obstacle.
"Change paragraph style without losing manual formatting" has some good points too.
Untitled.png
In my document I used Shift+Alt+RightArrow to apply the style "Heading 2".
Then the macro "HLinkForum" was run. This macro uses the contents of the clipboard to create a hyperlink to a post/topic in the Forum, AND applies a character style to indicate that is is a Hyperlink to the forum (rather than to the Wiki; or another part in ThisDocument; or to a web URL ...)

Now I am considering specialized macros "HlinkForum", "HlinkWiki", etc. which change only the Font Colour, or perhaps apply a Font Colour PLUS Italics.

I noted the algorithm to change font if a specified percentage content was reached, and the pitfalls surrounding that, but here I explicitly want the character style font to distinguish itself from the paragraph style font.

I'd appreciate any comments before I set to work.

Thanks, Chris
You do not have the required permissions to view the files attached to this post.
An expensive day out: Wallet and Grimace

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

Re: retaining PART of a character style over a Paragraph style.

Post by Jay Freedman »

As long as you use a paragraph style to apply the underlying paragraph settings and font settings, and a character style to modify the font settings of a part of the paragraph, there should be no problems.

You cannot apply two or more character styles to the same segment of text. The one applied last will override the previously existing one(s).

I'm a bit confused by the post's title: what "PART of a character style" do you intend to retain, under what circumstances?

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

Re: retaining PART of a character style over a Paragraph style.

Post by Charles Kenyon »

If the character style is used to format half or more of the paragraph, applying a paragraph style will remove it.
Like Jay, I do not understand what you mean by "part of a character style."\
You can create a character style that uses the underlying paragraph font. So, for instance, the default Strong style applies bold formatting to whatever the underlying paragraph style's font happens to be.

What is it you are trying to accomplish, Chris.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: retaining PART of a character style over a Paragraph style.

Post by ChrisGreaves »

Jay Freedman wrote:
03 May 2023, 20:49
As long as you use a paragraph style to apply the underlying paragraph settings and font settings, and a character style to modify the font settings of a part of the paragraph, there should be no problems. ,,, I'm a bit confused by the post's title: what "PART of a character style" do you intend to retain, under what circumstances?
Thanks for the response Jay.

The paragraph style "Heading 2" has a font definition of Arial, Bold, 21.5 pt, Colour:Automatic.
I have a character style "TutHlinkForum" which has a font definition of size 12 pt, Colour:Magenta

In writing that I see my mistake: assigning a font size to the character style "TutHlinkForum".
I have been thinking of that during this day.
I created the character style "TutHlinkForum" as clone of (probably) the default character style "Hyperlink", and carried that character style's font size with it.

The truth is that for me, only the colour of the hyperlink character styles matter:-
Magenta for links to Forum posts
Red for Wiki hyperlinks
Green for intra-document hyperlinks
Blue for web links


Sometimes I hyperlink a phrase of text, but often enough I will hyperlink a phrase in a Heading when that phrase leads to a major section in the Wiki, or perhaps to a chapter in the User manual.

I hope that this clears up your confusion.
Your remarks have certainly cleared up my confusion. :thankyou:
Thanks again,
Chris
An expensive day out: Wallet and Grimace

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

Re: retaining PART of a character style over a Paragraph style.

Post by Charles Kenyon »

Note that once your hyperlink field is triggered, the Followed Hyperlink style will be used regardless of the original style used on the link.

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15498
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: retaining PART of a character style over a Paragraph style.

Post by ChrisGreaves »

Charles Kenyon wrote:
04 May 2023, 12:36
Note that once your hyperlink field is triggered, the Followed Hyperlink style will be used regardless of the original style used on the link.
Thank you Charles; duly noted. And then experimented-with!
Untitled.png
I opened up a document and found three hyperlinks. I clicked on the first and then on the third, but left the second unused.

The first hyperlink changed changed from the standard Blue to what I think is a standard Purple (in MSWord2003)
The third hyperlink remained in its character style (Magenta) "TutHlinkForum"

I think that this contradicts your note, but am not certain of the term "Followed". I think that refers to the fact that "This hyperlink has already been followed (... been clicked-on)"
Cheers, Chris
You do not have the required permissions to view the files attached to this post.
Last edited by ChrisGreaves on 04 May 2023, 21:44, edited 1 time in total.
An expensive day out: Wallet and Grimace

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

Re: retaining PART of a character style over a Paragraph style.

Post by Charles Kenyon »

Yes, it does contradict what I predicted and (I think) my experience. I may have learned something! I've tested and my test corresponds to your results. I think my memory comes from modifying the Hiperlink style or basing a style on that style.