Public Sub ClearImmediateWindow()
Try
Dim vsWindowKindImmediateWindow As String _
= "{ECB7191A-597B-41F5-9843-03A4CF275DDE}"
Try
Dim obj As Object = System.Runtime.InteropServices.Marshal._
GetActiveObject("VisualStudio.DTE.10.0")
If obj IsNot Nothing Then
Dim DTE2 As EnvDTE80.DTE2 = CType(obj, EnvDTE80.DTE2)
For Each wndw As EnvDTE.Window In DTE2.Windows
If wndw.ObjectKind = vsWindowKindImmediateWindow Then
wndw.Activate()
DTE2.ExecuteCommand("Edit.ClearAll")
Exit For
End If
Next
End If
Catch comEx As COMException
' Not running from within the VS IDE?
Catch ex As Exception
Throw ex
End Try
Catch ex As Exception
' Handle this as you desire.
End Try
End Sub
End Sub
Public Sub ClearImmediateWindow()
Dim dte As EnvDTE80.DTE2 = Marshal.GetActiveObject("VisualStudio.DTE.11.0")
dte.Windows.Item("Immediate Window").Activate() 'Activate Immediate Window
dte.ExecuteCommand("Edit.SelectAll")
dte.ExecuteCommand("Edit.ClearAll")
Marshal.ReleaseComObject(dte)
End Sub