![]() |
#1
|
|||
|
|||
![]()
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 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 |
|
![]() |
||||
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 |
![]() |
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 |