I'm trying to write a macro, that will be triggered with a menu button, that will activate a specific module. If the module doesn't exist, then I want the macro to default to the sheet that the "View Code" tab menu activates.
Example:
Sub ShowComponent(byVal sh as WorkSheet)
Dim vbp As VBProject
Dim vbc as VBComponent
Set vbp = sh.Parent.VBProject
On Error Resume Next
Set vbc = vbp.VBComponents(sh.CodeName + "_Subs")
If Not vbc is Nothing Then
vbc.Activate
Else
Set vbc = vbp.VBComponents(sh.CodeName)
If Not vbc is Nothing Then
vbc.Activate 'doesn't work
End If
End If
End Sub
Bookmarks