Andreas Hermle
asked on
Manually format a couple of terms within a paragraph using VBA
Dear Experts:
Below macro applies a user-defined paragraph style (MyStyle) to the term ...
... Table of Contents (clickable entries). The Style 'MyStyle' has 18pt as font size.
How is this macro to be re-written so that after applying the paragraph style, the term (clickable entries) is reformatted to just 10pt font size.
I could create a user-defined character style and apply that character style but as a matter of fact, the current macro should manually format this term ('clickable entries', i.e. including the brackets) in one go.
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
Below macro applies a user-defined paragraph style (MyStyle) to the term ...
... Table of Contents (clickable entries). The Style 'MyStyle' has 18pt as font size.
How is this macro to be re-written so that after applying the paragraph style, the term (clickable entries) is reformatted to just 10pt font size.
I could create a user-defined character style and apply that character style but as a matter of fact, the current macro should manually format this term ('clickable entries', i.e. including the brackets) in one go.
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
Sub Apply_Style()
Dim myRange as Range
Set myRange = ActiveDocument.Content
myRange.Find.Execute FindText:="Table of Contents (clickable entries)", Forward:=True
If myRange.Find.Found = True Then
myRange.Style = "My_Style"
End If
End Sub
Yup
Chris
Sub Apply_Style()
Dim myRange As Range
Set myRange = ActiveDocument.Content
myRange.Find.Execute FindText:="Table of Contents (clickable entries)", Forward:=True
If myRange.Find.Found = True Then
myRange.Style = "My_Style"
myRange.Font.Size = 10
End If
End Sub
Chris
ASKER
Hi Chris,
thank you very much for your swift help.
My wording may have been a little bit confusing but ...
... I only would like part of this string to be reformatted to just 10 pt Font Size, ie. the part that says (cklickable entries).
The other part of the string, i.e. Table of Contents should retain its original style properties.
Regards, Andreas
thank you very much for your swift help.
My wording may have been a little bit confusing but ...
... I only would like part of this string to be reformatted to just 10 pt Font Size, ie. the part that says (cklickable entries).
The other part of the string, i.e. Table of Contents should retain its original style properties.
Regards, Andreas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Chris,
ok, this did the trick, thank you very much for your professional help.
Regards, Andreas
ok, this did the trick, thank you very much for your professional help.
Regards, Andreas
New line 8 as
My range.font.size = 10
Chris