Hi,
I know it is possible to add procedures and lines to a module through VBA, however is it possible to add procedures and lines to ThisOutlookSession?
Here is my code:
VB Code:
Public Sub cmdOK_click() Dim i As Integer Dim VBCodeMod As CodeModule Dim LineNum As Long Dim button_num As String Dim button_num_int As Integer [COLOR=Red][B]Set VBCodeMod = VBE.ActiveVBProject.VBComponents("ThisOutlookSession").CodeModule[/B][/COLOR] For i = old_num_DBs To new_num_DBs With VBCodeMod LineNum = .ProcCountLines("Application_MAPILogonComplete", vbext_pk_Proc) button_num = Right$(Left$(.Lines(.ProcBodyLine("Application_MAPILogonComplete", vbext_pk_Proc), 1), 18), 1) button_num_int = CInt(button_num) .InsertLines 1, "Public WithEvents oMnuTrackerSub" & button_num_int & " As Office.CommandBarButton" .InsertLines .ProcBodyLine("Application_MAPILogonComplete", vbext_pk_Proc), "Dim oCBmnuTracker" & button_num_int + 1 & " As Office.CommandBarButton" .InsertLines button_num_int + 10, "Set oCBmnuTracker" & button_num_int & " = oCBmnuAddToTrackerMain.Controls.Add(msoControlButton, 1, , , False)" .InsertLines LineNumb, "With oCBmnuTracker" & button_num_int _ & vbCr & " .BeginGroup = False" _ & vbCr & " .Caption = " & lstDBadd.ListItems(i) _ & vbCr & " .Enabled = True" _ & vbCr & " .Style = msoControlCustom" _ & vbCr & " .Visible = True" _ & vbCr & "End With" _ & vbCr & "Set oMnuTrackerSub" & button_num_int & " = oCBmnuTracker" & button_num_int button_added = True 'name_button_added = lstDBadd.ListItems(i) End With Next i Set VBCodeMod = Nothing End Sub
The red line is where my error occurs. Does anyone know how to reference ThisOutlookSession properly?




Reply With Quote