Forum Discussion
VBA - Range to include numbered lists
- May 17, 2023
Tom_Griffith Either use Undo, or close the document without saving it.
- Tom_GriffithMay 18, 2023Copper Contributor
Thanks again for your help on those two methods. I decided on the following (pseudo code.)
wordDoc.ConvertNumbersToText
var action_text=actionRange.FormattedText;
wordDoc.Undo
action_text=action_text.raplace(/\t\/," ")
...do insert stuff with action_text....
I was hoping to do a more precise Find.Execute on the Range to get rid of only the tabs inserted (number+tab+text) by ConvertNumberToText but I guess I'll live with a global tab replace on the text object (action_text) created from the Range. It'll dump any other tabs user may have put in but i think that'll be ok. I think doing any additional stuff after ConvertNumbersToText, like the Find.Replace, will shove the ConvertNumbersToText out as the Undo target. Thanks so much again.- May 18, 2023
Tom_Griffith Use
With ActiveDocument .UndoClear .ConvertNumbersToText Selection.Range.Text = Replace(Selection.Range.Text, vbTab, " ") 'do what you want to .Undo (3) 'may need to replace 3 to allow for other changes that you make End With