dj44
01-13-2017, 07:51 AM
Hi folks,
Good Friday the 13th :)
This is complex as I may preface.
I am needing some help and advice on how I may be able to convert something to a function.
I have spent a lot of time and just got no where on my function writing escapade so I have stripped back to basics.
The function opens to a specific module and sub procedure.
So as is it works normally.
But I shudder to have to repeat the same code for 20 macros so I rememebred you can make a function but that’s where I am stumped.
Sub OpenVBA1()
'GoToVBA("Module2","TestMacro")
End Sub
'Function GoToVBA( ## As Range -something here)
End Function
Sub OpenVBEGoToSpecificMacro()
Dim lStartLine As Long
Application.VBE.MainWindow.Visible = True
ThisDocument.VBProject.VBComponents("Module2").Activate
With Application.VBE.ActiveCodePane.CodeModule
lStartLine = .ProcStartLine("Test2", 0)
.CodePane.SetSelection lStartLine, 1, lStartLine, 1
End With
'https://www.pcreview.co.uk/threads/programmatically-open-vbe-and-go-to-a-specified-procedure-in-target-module.982766/
End Sub
Please take a look and advise.
It would be great if the function could just go to the sub name but you cant do that in word, in excel you can write the sub name and use application go to but not with word.
So im not sure what is best a class module?
Many thanks for your time
Good Friday the 13th :)
This is complex as I may preface.
I am needing some help and advice on how I may be able to convert something to a function.
I have spent a lot of time and just got no where on my function writing escapade so I have stripped back to basics.
The function opens to a specific module and sub procedure.
So as is it works normally.
But I shudder to have to repeat the same code for 20 macros so I rememebred you can make a function but that’s where I am stumped.
Sub OpenVBA1()
'GoToVBA("Module2","TestMacro")
End Sub
'Function GoToVBA( ## As Range -something here)
End Function
Sub OpenVBEGoToSpecificMacro()
Dim lStartLine As Long
Application.VBE.MainWindow.Visible = True
ThisDocument.VBProject.VBComponents("Module2").Activate
With Application.VBE.ActiveCodePane.CodeModule
lStartLine = .ProcStartLine("Test2", 0)
.CodePane.SetSelection lStartLine, 1, lStartLine, 1
End With
'https://www.pcreview.co.uk/threads/programmatically-open-vbe-and-go-to-a-specified-procedure-in-target-module.982766/
End Sub
Please take a look and advise.
It would be great if the function could just go to the sub name but you cant do that in word, in excel you can write the sub name and use application go to but not with word.
So im not sure what is best a class module?
Many thanks for your time