![]() |
|
#1
|
|||
|
|||
|
Hi, I have tried to tidy up/shorten the below macro to put all the functions to remove bold from para marks, commas, full stops, semi-colons into a single function but everything I try just doesn't seem to work. Can anyone help at all? Thanks, Shelley
Code:
With oRng.Find
'remove bold from para marks'
.Text = "^p"
.Replacement.Text = "^p"
.Replacement.Font.Bold = False
.Execute Replace:=wdReplaceAll
End With
With oRng.Find
'remove bold from semi colons
.Text = ";"
.Replacement.Text = ";"
.Replacement.Font.Bold = False
.Execute Replace:=wdReplaceAll
End With
With oRng.Find
'remove bold from commas
.Text = ","
.Replacement.Text = ","
.Replacement.Font.Bold = False
.Execute Replace:=wdReplaceAll
End With
With oRng.Find
'remove bold from full stops
.Text = "."
.Replacement.Text = "."
.Replacement.Font.Bold = False
.Execute Replace:=wdReplaceAll
End With
|
|
#2
|
|||
|
|||
|
You only need to find the bold ones, not all of them and you only need to replace the formatting, not the underlying text:
Code:
Sub ScratchMacro()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = "[" & Chr(13) & ".;,]"
.MatchWildcards = True
.Font.Bold = True
.Replacement.Font.Bold = False
.Execute Replace:=wdReplaceAll
End With
lbl_Exit:
Exit Sub
End Sub
|
|
#3
|
|||
|
|||
|
Thank you Graham for sorting this out, I've slotted it into the main macro and it works perfectly, many thanks best wishes, Shelley
|
|
#4
|
|||
|
|||
|
Well I'm not Graham but you are welcome just the same.
|
|
#5
|
|||
|
|||
|
Oh my apologies Greg lol but thank you for your kind assistance, the macro works perfectly very much appreciated
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Footnote extraction macro [Why is this macro so slow? / anyway to make it faster?]
|
Le_Blanc | Word VBA | 10 | 03-22-2021 11:38 AM |
| Spell check macro within macro button field doesn't work in one document | samuelle | Word VBA | 0 | 07-20-2016 02:27 AM |
Macro Question: Need help making a macro to highlight the first word in every sentence
|
LadyAna | Word | 1 | 12-06-2014 10:39 PM |
| Macro Needed to bold specific lines and Macro to turn into CSV | anewteacher | Word VBA | 1 | 05-28-2014 03:59 PM |
| custom icon, undo/redo for macro, permanent macro | Rapier | Excel | 0 | 08-05-2013 06:30 AM |