// you need to select something beforehand, but excluding start/end of line // to allow +1 and -1 for selection working right var sel = ActiveView.Selection; var text = ActiveDocument.GetText(sel); ActiveView.ShowQuickInfo(text); sleep(3000); var ptEnd = sel.end; sel.end = ptEnd; ActiveDocument.BeginUndoGroup(); sel.left -= 1; sel.right += 1; ActiveView.Select(sel); Output().writeln(ActiveDocument.GetText(sel)); sleep(1500); sel.left += 1; sel.right -= 1; ActiveView.Select(sel); sel.end = ActiveDocument.ReplaceText(sel, "New Text", HE_ACTION_UNKNOWN); sleep(1500); sel.end = ActiveDocument.ReplaceText(sel, text, HE_ACTION_UNKNOWN); sleep(1500); sel.end = ActiveDocument.InsertText(sel.start, "Inserted Text", HE_ACTION_UNKNOWN); sleep(1500); ActiveDocument.DeleteText(sel, HE_ACTION_UNKNOWN); sleep(1500); ActiveDocument.FlushUndoGroup();