View Single Post
 
Old 04-08-2019, 10:16 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

I'm guessing is it is because the search string includes the paragraph mark and with a replace, everything defined is replaced so in the resulting vacuum Word just thinks the style should be the one following. Something like this could be used as a work around:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Range
  Set oRng = ActiveDocument.Paragraphs(1).Range
  oRng.End = oRng.End - 1
  oRng.Text = Replace(oRng.Text, ",", " ", 1, , vbTextCompare)
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote