Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default programmatically open VBE and go to a specified procedure in target module?

Hello all,

Win 2000
Excel 2000

I am wondering if there is a way to programmatically open the VBE and
go to a specific
procedure or macro in the target module (in this example: basModule1).
I have the code to go
to the target module, but I can't seem
to figure out a way for the procedure to open at the target procedure
or macro.
I spent some time looking at the object model and searching the
microsoft.public.excel.programming newsgroup, no luck.
Might anyone out there have an answer?
Thank you in advance for any information you may provide.
Cheers,
Tom


Sub OpenVBE()
' Open the Visual Basic Editor Programmatically

Application.VBE.MainWindow.Visible = True
'The next line of code goes to a specified module
ThisWorkbook.VBProject.VBComponents("basModule1"). Activate

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default programmatically open VBE and go to a specified procedure in target module?

Hi DataFreakFromUtah,

I'm not well-versed with the VBE objects, but this seems to work:

Sub OpenVBE()
Dim lStartLine As Long

ThisWorkbook.VBProject.VBComponents("basModule1"). Activate

With Application.VBE.ActiveCodePane.CodeModule
lStartLine = .ProcStartLine("test2", 0)
.CodePane.SetSelection lStartLine, 1, lStartLine, 1
End With
End Sub


Just change the "test2" to the name of your procedure.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


DataFreakFromUtah wrote:
Hello all,

Win 2000
Excel 2000

I am wondering if there is a way to programmatically open the VBE and
go to a specific
procedure or macro in the target module (in this example: basModule1).
I have the code to go
to the target module, but I can't seem
to figure out a way for the procedure to open at the target procedure
or macro.
I spent some time looking at the object model and searching the
microsoft.public.excel.programming newsgroup, no luck.
Might anyone out there have an answer?
Thank you in advance for any information you may provide.
Cheers,
Tom


Sub OpenVBE()
' Open the Visual Basic Editor Programmatically

Application.VBE.MainWindow.Visible = True
'The next line of code goes to a specified module
ThisWorkbook.VBProject.VBComponents("basModule1"). Activate

End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default programmatically open VBE and go to a specified procedure in target module?

Thanks Jake!
I was able to make the procedure work by adding one line of code to
it:
Application.VBE.MainWindow.Visible = True
Apparently the procedure wouldn't work if the VBE wasn't all ready
open.
I am in Win 2000, Excel 2000, with VBEToolsReferencesMicrosoft VBA
Extensibility 5.3 checked.
The procedure that worked for me is below:



Sub OpenVBEGoToSpecificMacro()

Dim lStartLine As Long
Application.VBE.MainWindow.Visible = True
ThisWorkbook.VBProject.VBComponents("ModuleNameHer e").Activate

With Application.VBE.ActiveCodePane.CodeModule
lStartLine = .ProcStartLine("VBAProcedureNameHere", 0)
.CodePane.SetSelection lStartLine, 1, lStartLine, 1
End With
End Sub






"Jake Marx" wrote in message ...
Hi DataFreakFromUtah,

I'm not well-versed with the VBE objects, but this seems to work:

Sub OpenVBE()
Dim lStartLine As Long

ThisWorkbook.VBProject.VBComponents("basModule1"). Activate

With Application.VBE.ActiveCodePane.CodeModule
lStartLine = .ProcStartLine("test2", 0)
.CodePane.SetSelection lStartLine, 1, lStartLine, 1
End With
End Sub


Just change the "test2" to the name of your procedure.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


DataFreakFromUtah wrote:
Hello all,

Win 2000
Excel 2000

I am wondering if there is a way to programmatically open the VBE and
go to a specific
procedure or macro in the target module (in this example: basModule1).
I have the code to go
to the target module, but I can't seem
to figure out a way for the procedure to open at the target procedure
or macro.
I spent some time looking at the object model and searching the
microsoft.public.excel.programming newsgroup, no luck.
Might anyone out there have an answer?
Thank you in advance for any information you may provide.
Cheers,
Tom


Sub OpenVBE()
' Open the Visual Basic Editor Programmatically

Application.VBE.MainWindow.Visible = True
'The next line of code goes to a specified module
ThisWorkbook.VBProject.VBComponents("basModule1"). Activate

End Sub

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 81
Default programmatically open VBE and go to a specified procedure in target module?

Have you tried, simply:

Sub Test()
Application.Goto "MyRoutine"
End Sub

Regards,
Peter

-----Original Message-----
Thanks Jake!
I was able to make the procedure work by adding one line

of code to
it:
Application.VBE.MainWindow.Visible = True
Apparently the procedure wouldn't work if the VBE wasn't

all ready
open.
I am in Win 2000, Excel 2000, with

VBEToolsReferencesMicrosoft VBA
Extensibility 5.3 checked.
The procedure that worked for me is below:



Sub OpenVBEGoToSpecificMacro()

Dim lStartLine As Long
Application.VBE.MainWindow.Visible = True
ThisWorkbook.VBProject.VBComponents

("ModuleNameHere").Activate

With Application.VBE.ActiveCodePane.CodeModule
lStartLine = .ProcStartLine

("VBAProcedureNameHere", 0)
.CodePane.SetSelection lStartLine, 1,

lStartLine, 1
End With
End Sub






"Jake Marx" wrote in message

...
Hi DataFreakFromUtah,

I'm not well-versed with the VBE objects, but this

seems to work:

Sub OpenVBE()
Dim lStartLine As Long

ThisWorkbook.VBProject.VBComponents

("basModule1").Activate

With Application.VBE.ActiveCodePane.CodeModule
lStartLine = .ProcStartLine("test2", 0)
.CodePane.SetSelection lStartLine, 1,

lStartLine, 1
End With
End Sub


Just change the "test2" to the name of your procedure.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address

unmonitored]


DataFreakFromUtah wrote:
Hello all,

Win 2000
Excel 2000

I am wondering if there is a way to programmatically

open the VBE and
go to a specific
procedure or macro in the target module (in this

example: basModule1).
I have the code to go
to the target module, but I can't seem
to figure out a way for the procedure to open at the

target procedure
or macro.
I spent some time looking at the object model and

searching the
microsoft.public.excel.programming newsgroup, no luck.
Might anyone out there have an answer?
Thank you in advance for any information you may

provide.
Cheers,
Tom


Sub OpenVBE()
' Open the Visual Basic Editor Programmatically

Application.VBE.MainWindow.Visible = True
'The next line of code goes to a specified module
ThisWorkbook.VBProject.VBComponents

("basModule1").Activate

End Sub

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default programmatically open VBE and go to a specified procedure in target module?

Peter T wrote:
Have you tried, simply:

Sub Test()
Application.Goto "MyRoutine"
End Sub


Nice catch, Peter! I didn't think of that one.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW TO CARRY A VAIABLE RESULTS FROM EXCEL SHEET PROCEDURE TO A MODULE CAPTGNVR Excel Discussion (Misc queries) 5 February 2nd 07 07:05 PM
to call procedure in a worksheet in a module CAPTGNVR Excel Discussion (Misc queries) 4 January 30th 07 09:39 PM
Add reference programmatically before a module compiles Wexler Excel Programming 0 June 14th 04 05:18 PM
Lines in a Module(Procedure) Juan Melero Excel Programming 6 December 30th 03 12:38 AM
Programmatically open / edit vba-editor hglamy[_2_] Excel Programming 1 September 4th 03 03:32 PM


All times are GMT +1. The time now is 07:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"