![]() |
#1
|
|||
|
|||
![]()
I have VBA code that has the following line of code:
Code:
SRCdoc.Paragraphs(iPara).Range.Text = _ Replace(SRCdoc.Paragraphs(iPara).Range.Text, ",", " ", 1, , vbTextCompare) The particular case I am currently investigating is one in which there are no commas in the paragraph, so the REPLACE statement should not change the paragraph, yet, it always inherits the style of the subsequent paragraph. This happens when the following paragraph is a custom style and when it is the default 'normal' style. Help would be much appreciated. |
#2
|
|||
|
|||
![]()
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 |
#3
|
||||
|
||||
![]()
Cross-posted at: https://social.msdn.microsoft.com/Fo...?forum=worddev
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Tags |
inheritance, style |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Inconsistent paragraph style | electricaltill | Word | 10 | 01-06-2016 10:09 AM |
![]() |
CTwriter | Word | 3 | 01-25-2013 12:38 AM |
Paragraph Style for Thesis | groxby | Word | 1 | 03-24-2012 04:45 AM |
![]() |
Jennifer Murphy | Word | 3 | 02-16-2012 04:18 PM |
Character style stripped while applying paragraph style | sams_gates | Word | 0 | 08-29-2009 02:03 AM |