Opening the Immediate window with VBA

daievans

Registered User.
Local time
Yesterday, 18:50
Joined
Apr 3, 2013
Messages
75
OK - I can get the Code window to open when I run the program by using
Code:
Application.VBE.MainWindow.Visible = True

To be honest, it's not a lot of use as it sits there doing nothing ... Far better for me to have the "Immediate" window open ... How do I do that from within VBA ...

I can then watch my program go through its many loops and marvel at my ingenuity ;) - and it tells me what it was doing *if* it fails ....:cool:

Hope everyone is well around here - as I am - having just returned from vacation in God's own country ...
 
Code:
Application.VBE.Windows.Item("Immediate").SetFocus

Linq ;0)>
 
Does this work?
With Application.VBE.MainWindow
..Visible = True
..SetFocus
End With

or
Application.SendKeys "%{F8}"

In Excel - to open it and make it go to a specific line of code in a procedure, I copied some old archive code and manually attempted to modify it for Access No idea if it will do what you want:
Code:
Sub Test(ModuleName As String)
      Dim lStartLine As Long
10    Application.VBE.MainWindow.Visible = True
20    Application.VBE.VBProject.VBComponents(ModuleName).Activate

30    With Application.VBE.VBProject.ActiveCodePane.CodeModule
40    lStartLine = .ProcStartLine("VBAProcedureNameHere", 0)
50    .CodePane.SetSelection lStartLine, 1, lStartLine, 1
60    End With
          
      ' OR
70        With Application.VBE.MainWindow
80            .Visible = True
90            .SetFocus
          
100       Application.VBE.VBProject.Goto "MyRoutine"
110       End With
End Sub
 

Users who are viewing this thread

Back
Top Bottom