Advertisement
AlanElston

Immediate Window Clear Open Close with VBA

Feb 23rd, 2019
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub ImmediateWindowOpenClearCloseProgramatically()
  2.     If Application.VBE.MainWindow.Visible = False Then Application.SendKeys Keys:="%{F11}" ' VB Editor window  Alt+F11
  3. Application.SendKeys Keys:="^g" ' Immediate Window  Ctrl+g
  4. DoEvents: DoEvents
  5.  Debug.Print "Hello," & vbCr & vbLf & "Hopefully this will all be cleared in a few seconds"
  6.  MsgBox Prompt:="Hello, click OK , then after this procedure is finished I open the Immediate window which theoretically I should have already done"
  7.  DoEvents: DoEvents
  8.  Application.OnTime earliesttime:=Now + TimeValue("0:00:03"), procedure:="WipeMy_" ' Clear Immediate Window
  9. Application.OnTime earliesttime:=Now + TimeValue("0:00:06"), procedure:="Trash_t" ' Close windows
  10. End Sub
  11. Public Sub Trash_t() ' Close Windows
  12. On Error Resume Next ' Add the "Name"  for your Excel language version
  13. Application.VBE.Windows("Immediate").Close ' English Excel
  14. Application.VBE.Windows("Direktbereich").Close ' German Excel
  15. On Error GoTo 0
  16.  Let Application.VBE.MainWindow.Visible = False
  17. End Sub
  18. Public Sub WipeMy_() ' Clear Immediate Window
  19. Application.SendKeys "^g ^a {DEL} " ' {HOME}"
  20. End Sub
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. ' https://www.excelforum.com/excel-programming-vba-macros/343845-docking-project-explorer-vertically-2.html#post4545938
  40. ' https://www.excelcampus.com/vba/vba-immediate-window-excel/
  41. ' https://social.msdn.microsoft.com/Forums/office/en-US/da87e63f-676b-4505-adeb-564257a56cfe/vba-to-clear-the-immediate-window?forum=exceldev
  42. ' https://www.excelcampus.com/vba/vba-immediate-window-excel/#comment-90911
  43. ' http://www.eileenslounge.com/viewtopic.php?f=30&t=29579#p229156
  44. ' http://dailydoseofexcel.com/archives/2004/06/09/clear-the-immediate-window/#comment-1045809
  45. ' http://www.eileenslounge.com/viewtopic.php?f=30&t=31260#p242289
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement