Hello,
When I perform the following code:
Dim italicSaveRange As Word.Range
Dim savedItalic As Variant
Dim someRange As Word.Range
Set italicSaveRange = someRange.Duplicate
italicSaveRange.Collapse (WdCollapseEnd)
savedItalic = italicSaveRange.Italic
someRange.Italic = True
italicSaveRange.Italic = savedItalic
I expected that any text entered at the cursor or inserted into someRange
a la:
someRange.InsertAfter "Lorem ipsum..."
would not be italic (assuming that the formatting was not italic at this position previously, of course.) But it is. Help.
Based on your suggestion I now have the following, which appears to be working. It may be a fragile solution, depending on what gets moved around in the meantime (e.g., try typing some italic text into Word, ctrl-i to prepare to use non-italic, but then move the cursor left into the italics and then right out again; the cursor is inserting italic text...), but for my purposes where I am adding text elsewhere (but at a different level of the code so that I cannot access the text to insert at this level) this will probably work. Thank you.
Set italicSaveRange = someRange.Duplicate
italicSaveRange.Collapse (WdCollapseEnd)
savedItalic = italicSaveRange.Italic
someRange.Italic = True
italicSaveRange.InsertAfter SP
italicSaveRange.Characters(1).Italic = savedItalic
italicSaveRange.Characters(1).Delete