Paul and Greg,
thank you very much for this. Both Greg's and Paul's solutions worked for me.
I used this for flattening lists, they needed to be converted to plain text paragraphs (including the list number). This is probably going to end the issues we had with it concerning the italics.
A trimmed down code example is now:
Code:
Public Sub flattenLists()
Dim strListNr As String
Dim wPara As Word.Paragraph
Dim wList as Word.List
For Each wList In Word.ActiveDocument.Lists
With wList
For Each wPara In .ListParagraphs
wPara.range.Select
With wPara
strListNr = .range.ListFormat.ListString
.range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph
wPara.Range.ParagraphFormat.Reset
.range.InsertBefore strListNr & Chr(32)
End With
Next
End With
Next
End Sub
I am still curious what is happening when I use the old code. Googling around I found more mentions of this problem, some from ten years back. Is my conclusion right that setting the paragraph style is in the danger zone when it comes to macro's?
Thanks again, Ruud