This documentation is archived and is not being maintained.

IsOpen Property (General Extensibility)

Visual Studio .NET 2003

Determines if an undo operation is currently in effect or if a solution is open.

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

Return Value

True if an undo operation is in effect or if a solution is open, False if not.


An undo operation is in effect if the UndoContext object is open.

An open solution does not necessarily have a solution (.sln) file, because it might not have been saved yet.


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

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

   ' Check to see if UndoContext object is already open.
   If DTE.UndoContext.IsOpen = True Then
      boolWasOpen = True
      ' Open the UndoContext object to track changes.
      DTE.UndoContext.Open("RemoveNewLines", False)
   End If

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

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

See Also

AddFromFile Method (Solution Object) | AddFromTemplate Method (Solution Object) | Open Method (General Extensibility) | Saved Property (General Extensibility) | IsAborted Property | Open Method (UndoContext Object)

Applies To: Solution Object | UndoContext Object