VBE IMMEDIATE WINDOW

Hello,

Debug.Print "TEXT" send/print "TEXT" to VBE immediate window
OR
for x=1 to 100 'send/print 1 2 3 4 5 6 ....... 100 to VBE immediate window
debug.print x
next

How can clear immediate window, using VBA code?

Greetings!

  • why?

    watch, debug, local, immediate, command, output window are tools for turn easy development

    • Now It's hard for me to explain, but I need it

      • ok, but ...

        Sub test()
        Dim obj As Object
        Set obj = Application.VBE
        For I = 1 To obj.Windows.Count
        If obj.Windows.Item(I).Caption = "Immediate" Then
        Debug.Print (obj.Windows.Item(I).Caption)
        obj.Windows.Item(I).SetFocus
        SendKeys "^{Home}", True
        SendKeys "^+{End}", True
        SendKeys "{Del}", True
        End If
        Next I
        End Sub

        • Hello,
          I thank for Your answer!
          Below is my code to empty immediate window

          Sub immediate_window_BhBp_clear()
          'CLEAR IMMEDIATE WINDOW
          Set WshShell = CreateObject("WScript.Shell")
          WshShell.SendKeys "^g^a{DEL}"
          End Sub

          How to run code above
          .
          Place this code in any Macros module
          Open VBE
          Press Ctrl-g 'to open immediate window

          print "immediate" in immediate window
          Press Ctrl-space 'drop down list with macros beginning with "immediate" appears
          Select necessary macro using mouse or arrows - immediate_window_BhBp_clear
          Press key Enter

          I see, that You use 
          SendKeys "{Del}", True
          I don't understand why SendKeys "{Del}", True return error Permission denied
          I am forced to use workaround code using
          Set WshShell = CreateObject("WScript.Shell")
          WshShell.SendKeys "^g^a{DEL}"
           

          Greetings!

      • Easy

        Sub clearimmediatewindow()
        Dim i%

        For i = 1 To 250
        Debug.Print
        Next i

        End Sub

        • I thank for Your answer!

          Macro below prints 1 

          Sub immediate_window_BhBp_put_in()
          'PUT IN IMMEDIATE WINDOW
          For X = 1 To 200 'immediate have no more then 200 lines If Debug.Print 200 empty lines, immediate window is clearing

          'You may show this when use this code:
          'For X = 1 To 1000
          Debug.Print X
          Next
          'Set WshShell = CreateObject("WScript.Shell")
          'WshShell.SendKeys "^g^{HOME}" 'goto first line
          End Sub

          How to run this code.
          Place this code in any Macros module
          Open VBE
          Press Ctrl-g

          print "immediate" in immediate window
          Press Ctrl-space 'drop down list with macros beginning with "immediate" appears
          Select necessary macro using mouse or arrows - mmediate_window_BhBp_put_in
          Press key Enter

          Greetings!