![]() |
#1
|
|||
|
|||
![]()
I have a Word document which has Hyperlinks which may contain subscripts. I have a special Character Style("MyStyle"), which I sometimes need to convert these Hyperlinks to. But if I select each Hyperlink as a Range and then change the Range.Font to MyStyle, the Range.Text all returns to plain, and the subscripts are lost. I have tried pasting the Range Text after the Range and then using a For Loop to try and duplicate the Font Attributes, also creating a second Range and again using a For Loop, all to no avail.
newRg = .Range.Duplicate newRg.SetRange(.Range.Start + Len(.Range.Text), .Range.End + Len(.Range.Text)) newRg.Select() ' This attempt to move newRg to after .Range has no effect newRg.Start = .Range.Start + Len(.Range.Text) newRg.End = .Range.End + Len(.Range.Text) ' Nor does this ... The second part of the problem is the Font Change: newRg.Style = "MyStyle" 'here the subscripts are lost For i = 1 To .Range.Characters.Count newRg.Characters(i + Len(.Range.Text)).Font.Subscript = .Range.Characters(i).Font.Subscript Next ' And this has no effect at all. I fear I am missing something very fundamental! Could anyone help please? If I could simply get the two (identical) ranges positioned one after the other, then I could use the For Loop as shown. But duplicating the range and then trying to move it does not seem to work. Last edited by CharlieM; 08-04-2021 at 10:34 PM. |
Tags |
copying ranges, range styles/fonts |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to write individual lines of text with changing attributes. | sts023 | Word VBA | 0 | 05-26-2019 07:43 AM |
![]() |
AustinBrister | Word VBA | 19 | 08-22-2016 05:18 PM |
Changing font | TonyH | Outlook | 0 | 05-22-2014 07:58 AM |
![]() |
blaze | Word VBA | 1 | 04-15-2012 02:21 AM |
changing font size without changing leading | carolns | Word | 1 | 09-14-2009 12:30 PM |