![]() |
|
#1
|
||||
|
||||
![]()
Does this work? Make sure you test the result after pasting into your rich text editor
Code:
Sub Macro2() With Selection.Find .Text = "" .Replacement.Text = "" .ClearFormatting .Style = ActiveDocument.Styles("Endnote Reference") .Replacement.ClearFormatting .Replacement.Font.Superscript = True .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchWildcards = False .MatchSoundsLike = False .MatchAllWordForms = False .Execute Replace:=wdReplaceAll End With End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#2
|
|||
|
|||
![]()
Thanks Andrew, however this script doesn't seem to change the formatting. Still getting the same result when pasted. Running the following code to inspecting the style on each character after running your code shows as below. Not sure how to get rid of these pesky Endnote References
Code:
Sub formatCheck() Dim rng_character As Range For Each rng_character In ActiveDocument.Characters Debug.Print (rng_character.Text & " " & rng_character.Style) Next rng_character End Sub e Normal s Normal t Normal 1 Endnote Reference Normal T Normal e Normal s Normal t Normal 2 Endnote Reference |
#3
|
|||
|
|||
![]()
I think I've got it worked out. I saw mention on another forum from 2021 (sorry, didn't save the link) that there is a bug in Word when trying to modify character styles through a find. Of course, since this has to process every character in the document, is too slow to use on large docs. I'll continue to work on this so I don't have to check every character individually.
So I did this and it fixed it. The previous Endnote Reference is now Normal. Code:
Sub test() ' Remove Endnote Reference character style Dim rngDoc As Range Dim rngChar As Range Set rngDoc = ActiveDocument.Range For Each rngChar In rngDoc.Characters If rngChar.Style = "Endnote Reference" Then rngChar.Font.Reset rngChar.Font.Superscript = True End If 'rngChar.Style Next rngChar For Each rngChar In ActiveDocument.Range.Characters Debug.Print (rngChar.Text & ", " & rngChar.Style) Next rngChar End Sub T, Normal e, Normal s, Normal t, Normal 1, Normal Pastes as superScript into website's rich text editor. |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem with copying/pasting from web to word 2016 | cricket1001 | Word | 2 | 07-20-2020 07:00 PM |
![]() |
sai | Word VBA | 12 | 05-11-2020 04:29 AM |
Problem pasting mixed content from webpage into Word 2007 | silverman166 | Word | 0 | 02-17-2020 03:46 AM |
Word 2000--Problem with format retention when pasting | JerryL | Word | 2 | 01-05-2014 07:20 PM |
Copy and pasting problem Word 2010 | Sarah262 | Word | 3 | 08-16-2012 03:46 PM |