Hyperlink to Modules

Nalani

Well-known Member
Joined
Apr 10, 2009
Messages
1,047
Is it possible to Hyperlink to a Module?

I have a list of all my Modules.
Module1, Module2, etc. (of course with meaningful names)

What I'm looking for is if there is a way to click on Module1 from the List, it will open that module in the VBE for whatever I want to do with it, read, modify, etc.

I've done some searching but only found a way to Run it. Don't want to Run, just Open for Viewing/Modification.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Alt-F11, then Ctrl-R (if needed), then double click on the module name.

I don't know of any way to do this, maybe SendKeys but that's not my favourite type of codes.
 
Upvote 0
Thanks for the Look wigi

First of all, What does Ctrl-R do?

Tried your suggestion, but don't think I got it.

From the List of modules(on a worksheet within the workbook), I am trying(wanting) to turn the Name into a Hyperlink to that particular Module.

And I know the question is Why, just do Alt-F11 and the list is there to do a double click on the Name to open it.

I'm just trying to do something a little different for what I'm working on.
 
Upvote 0
Okay, I got it after some research :-D and with Chip's site on VBE for the objects, but most of it is my merit ;-)

Code:
Sub MyProcedure()

    On Error Resume Next
    Dim ProcKind As VBIDE.vbext_ProcKind
    With ActiveWorkbook.VBProject.VBComponents(InputBox("Please provide the module name", "Module name", "Module1")).CodeModule
        Application.Goto .ProcOfLine(.CountOfDeclarationLines + 1, ProcKind)
    End With

End Sub

The module chosen should have a least 1 procedure.

Wigi
 
Upvote 0
I was not happy with the condition that the module should have at least 1 procedure. So here's code that does not require this:

Code:
Sub MyProcedure()

    On Error Resume Next
    Dim ProcKind As VBIDE.vbext_ProcKind
    With ActiveWorkbook.VBProject.VBComponents(InputBox("Please provide the module name", "Module name", "Module1")).CodeModule
        If .CountOfLines > .CountOfDeclarationLines Then
            'there is at least 1 procedure in the module
            Application.Goto .ProcOfLine(.CountOfDeclarationLines + 1, ProcKind)
        Else
            'there are no procedures in the module: make a temporary procedure, jump to it and remove the procedure again
            .InsertLines 1, "Sub TestProc()"
            Application.Goto "TestProc"
            .DeleteLines 1
        End If
    End With

End Sub

Quite nifty code :-D
 
Upvote 0
I thank you for the time and research you are spending on this.

I tried your code out and it does do what is intended, Opens Module1.

Being that I have a List of all Modules, I really don't need the MsgBox.

I was thinking that with a DoubleClick_Event (or some other way) on the cell that has the Name in it, it might be able to jump to that Module.

Macro List

<TABLE style="BACKGROUND-COLOR: #ffffff; PADDING-LEFT: 2pt; PADDING-RIGHT: 2pt; FONT-FAMILY: Arial,Arial; FONT-SIZE: 10pt" border=1 cellSpacing=0 cellPadding=0><COLGROUP><COL style="WIDTH: 30px; FONT-WEIGHT: bold"><COL style="WIDTH: 64px"></COLGROUP><TBODY><TR style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt; FONT-WEIGHT: bold"><TD> </TD><TD>A</TD></TR><TR style="HEIGHT: 22px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">1</TD><TD>Macro1</TD></TR><TR style="HEIGHT: 22px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">2</TD><TD>Macro2</TD></TR><TR style="HEIGHT: 22px"><TD style="TEXT-ALIGN: center; BACKGROUND-COLOR: #cacaca; FONT-SIZE: 8pt">3</TD><TD>Macro3</TD></TR></TBODY></TABLE>

Excel tables to the web >> http://www.excel-jeanie-html.de/index.php?f=1" target="_blank"> Excel Jeanie HTML 4
i.e.
DoubleClick on A3 and it opens Macro3.

I did try to modify your code with no luck.

By the way......I also used Chip's site to Create my list of Macros. Couldn't find what you found for your code though.
 
Last edited:
Upvote 0
Do you have a list of modules, or of procedures?
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,786
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top