Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2019, 07:19 AM
WADEVCAMP WADEVCAMP is offline Why does paragraph inherit style of the following paragraph? Windows 10 Why does paragraph inherit style of the following paragraph? Office 2016
Novice
Why does paragraph inherit style of the following paragraph?
 
Join Date: Apr 2019
Posts: 1
WADEVCAMP is on a distinguished road
Default Why does paragraph inherit style of the following paragraph?

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)
My question is why this line of code causes the paragraph to inherit the style of the FOLLOWING paragraph.

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.
Reply With Quote
  #2  
Old 04-08-2019, 10:16 AM
gmaxey gmaxey is offline Why does paragraph inherit style of the following paragraph? Windows 10 Why does paragraph inherit style of the following paragraph? Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
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
  #3  
Old 04-08-2019, 02:13 PM
macropod's Avatar
macropod macropod is offline Why does paragraph inherit style of the following paragraph? Windows 7 64bit Why does paragraph inherit style of the following paragraph? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply

Tags
inheritance, style

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inconsistent paragraph style electricaltill Word 10 01-06-2016 10:09 AM
Why does paragraph inherit style of the following paragraph? Removing a paragraph style from the TOC CTwriter Word 3 01-25-2013 12:38 AM
Paragraph Style for Thesis groxby Word 1 03-24-2012 04:45 AM
Why does paragraph inherit style of the following paragraph? Style seems to inherit bold setting from previous style 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft