Use VBA to Clear Immediate Window?

前端 未结 16 1238
刺人心
刺人心 2021-01-30 00:19

Does anyone know how to clear the immediate window using VBA?

While I can always clear it myself manually, I am curious if there is a way to do this programmatically.

16条回答
  •  没有蜡笔的小新
    2021-01-30 00:53

    I tested this code based on all the comments above. Seems to work flawlessly. Comments?

    Sub ResetImmediate()  
            Debug.Print String(5, "*") & " Hi there mom. " & String(5, "*") & vbTab & "Smile"  
            Application.VBE.Windows("Immediate").SetFocus  
            Application.SendKeys "^g ^a {DEL} {HOME}"  
            DoEvents  
            Debug.Print "Bye Mom!"  
    End Sub
    

    Previously used the Debug.Print String(200, chr(10)) which takes advantage of the Buffer overflow limit of 200 lines. Didn't like this method much but it works.

提交回复
热议问题