Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-15-2021, 03:25 AM
rgros rgros is offline setting paragraph style removes inlines incidentally. Why? Windows 10 setting paragraph style removes inlines incidentally. Why? Office 2019
Novice
setting paragraph style removes inlines incidentally. Why?
 
Join Date: Jan 2021
Posts: 8
rgros is on a distinguished road
Default setting paragraph style removes inlines incidentally. Why?

Hi, I am new to this forum. I hope I manage to ask this question properly in one go.

The problem I am facing: I have a whole lot of word macro's running on documents to prepare it for conversion to XML.
Last week, I got a report of italic inlines disappearing in the macro output.
I traced this back to a routine that removes the paragraph styles from the document. In some cases the setting of the paragraph style has a side effect that italic inlines are removed.
I certainly want to preserve them in order to get the expected output.

I made a minimal example to show this behaviour.
I hope you can explain me why word behaves like this and that you can advise me what I can do in the macro are to prevent this from happening.

I have a document that looks like this:

abcdef 123456
abcdef 1234567
abcdef 12345
abcdef 1234

I run this macro on it to remove any user defined paragraph styles:
Code:
Public Sub flatten() 
    Dim wPara As Word.Paragraph 
      For Each wPara In Word.ActiveDocument.Paragraphs
         wPara.range.Select
         wPara.style = ActiveDocument.styles(wdStyleNormal).NameLocal
     Next
 End Sub
The result is:

abcdef 123456
abcdef 1234567
abcdef 12345
abcdef 1234

in the first two lines, the italic inline is deleted, whereas the last two lines still have it.


I found out the inline is deleted when the number of inline characters exceeds the number of normal characters (this is the case in the first two paragraphs).

As said, I want to preserve the inlines in all situations. I hope this is not a FAQ that I missed.

Thanks in advance, Ruud
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA - (Re-) Setting a Table Style mikejvir PowerPoint 2 12-04-2019 10:15 AM
Why does paragraph inherit style of the following paragraph? WADEVCAMP Word VBA 2 04-08-2019 02:13 PM
Setting part of a paragraph bold Fred256 Word VBA 4 10-07-2016 02:54 PM
setting paragraph style removes inlines incidentally. Why? 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 07:49 PM.


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