I need to create the following at runtime in vb.net
Private Sub Workbook_Open()
Application.OnKey "^q", "openForm"
in an excel spread sheet.
I can create a Module
Dim oModule As VBIDE.VBComponent
oModule = book.VBProject.VBComponents.Add(VBIDE.vbext_ComponentType.vbext_ct_StdModule)
scode = "Sub openForm()" & vbCr & "Userform1.show" & vbCr & "end sub"
' Add the VBA macro to the new code module.
but I need to have the sub in th "Thisworkbook" I know it has some thing to do with vbext_ct_doucment but I cant get to add.