This documentation is archived and is not being maintained.

IsAborted Property

Visual Studio .NET 2003

Returns whether the UndoContext object operation was terminated by the SetAborted method.

[Visual Basic .NET]
Public ReadOnly Property IsAborted() As Boolean
[Visual Basic 6]
Property Get IsAborted() As Boolean
HRESULT __stdcall get_IsAborted(
   /* [out, retval] */ VARIANT_BOOL* retVal
public bool IsAborted {get;}
[JScript .NET]
public function get IsAborted() : Boolean

Return Value

True if the operation was aborted, False if not.


If the UndoContext object is disabled by SetAborted before being closed, all changes made to participating documents will be discarded when the UndoContext object is closed.


This example removes all newline characters from a block of selected text:

Sub IsAbortedExample()
   ' Before running, select text in an open document.
   Dim txtSel As TextSelection
   Dim strTS As String, strAnswer As String, bIsOpen As Boolean
   txtSel = DTE.ActiveDocument.Selection
   strTS = txtSel.Text

   ' Check to see if UndoContext object is already open.
   If DTE.UndoContext.IsOpen = True Then
      bIsOpen = True
      ' Open the UndoContext object to track changes.
      DTE.UndoContext.Open("RemoveNewLines", False)
   End If
   MsgBox("Current IsAborted value: " & DTE.UndoContext.IsAborted)

   ' Perform search for newline characters and remove them.
   If strTS <> "" Then
      strTS = Replace(strTS, vbNewLine, "", Compare:=vbTextCompare)
   End If

   ' Check to see if you want to discard changes.
   strAnswer = MsgBox("Do you want to discard all changes made?", vbYesNo & vbQuestion)
   If strAnswer = True Then
      MsgBox("Current IsAborted value: " & DTE.UndoContext.IsAborted)
   End If

   ' If UndoContext was already open, don't close it.
   If bIsOpen = True Then
      ' Close the UndoContext object to commit the changes.
   End If
End Sub

See Also

SetAborted Method

Applies To: UndoContext Object