I would like to add a code to clear immediate window.
When programming I like to use debug.print. To make the debug.print a bit more convenient, I wrote a small code below. A problem occurs, when clearing the immediate window. On my machine this code clears the immediate window, write all the debug.print entries an then clears it again. I searched a lot codes and tried many of them without success. I appreciate your answer - thanks!
Sub dp(Optional Identifier As String, Optional v As Variant, Optional ClearWindow As Boolean, Optional blnLineTop As Boolean, Optional blnLineEnd As Boolean)
'=================================================================================
'make debug.print more comfortable
'
'copy this: Call dp(Identifier ,v ,ClearWindow ,blnLineTop ,blnLineEnd)
'
'=================================================================================
'variables
Dim i As Long
Dim sLine As String: sLine = "--------------------------------------------"
'Pre
If ClearWindow Then
With Application.VBE.Windows("Direktbereich")
.Visible = True
.SetFocus
Application.SendKeys "^g ^a {DEL}"
Application.SendKeys ("{F7}")
End With
End If
'Main
If Identifier = "" And IsEmpty(v) = Empty And ClearWindow = False And blnLineTop = False And blnLineEnd = False Then
Debug.Print
Else
Select Case Identifier
Case Is <> vbNullString
If blnLineTop Then Debug.Print sLine
If IsArray(v) Then
For i = 1 To UBound(v)
Debug.Print Identifier & " (" & (i) & ")", " : ", CStr(v(i))
Next
Else
Debug.Print Identifier, " : ", CStr(v)
End If
If blnLineEnd Then Debug.Print sLine
Case Is = vbNullString
If blnLineTop Then Debug.Print sLine
If blnLineEnd Then Debug.Print sLine
End Select
End If
End Sub