Reputation: 370
I am trying to revive / recompile an old Outlook Plugin that was written in VB6 however I am getting an error seemingly related to setting a button on the Ribbon bar. Just cannot work out why and would appreciate any feedback / guidance.
The Plugin still works fine on Outlook 2003 on Windows 7 for both x86 and x64
The issue though is trying to recompile it so I can tweak it and also have it run with the more recent versions of Outlook name 2013 - 2018
In compiling I am getting - Error in loading DLL for xxxx.CommandBars ( Lines 40 and I presume also 70 )
Public Function CreateTSEButton() As Boolean
10 On Error GoTo CreateTSEButton_Error
20 If Not objExplorer Is Nothing Then
Dim mCommandBar As CommandBar
30 On Error Resume Next
40 Set mCommandBar = objExplorer.CommandBars("E-mail")
50 On Error GoTo 0
60 If mCommandBar Is Nothing Then
70 Set mCommandBar = objExplorer.CommandBars("Standard")
80 End If
90 If mCommandBar Is Nothing Then Exit Function
'Command Bar Initialized, Now Find the Control First
Dim mControl As Object
100 For Each mControl In mCommandBar.Controls
110 If UCase$(Trim$(TypeName(mControl))) = UCase$(Trim$("CommandBarButton")) Then
120 If UCase$(Trim$(mControl.Caption)) = UCase$(Trim$(IDS_TSE_ON)) Or UCase$(Trim$(mControl.Caption)) = UCase$(Trim$(IDS_TSE_OFF)) Then
'Button Found
130 Set mTSEButton = mControl
140 Exit For
150 End If
160 End If
170 Next
180 If Not mTSEButton Is Nothing Then
190 Call UpdateButtonStatus
200 Else
210 Set mTSEButton = mCommandBar.Controls.add(msoControlButton, , , , True)
220 mTSEButton.Style = msoButtonIconAndCaption
230 mTSEButton.BeginGroup = True
240 mTSEButton.Enabled = True
250 mTSEButton.Visible = True
260 Call UpdateButtonStatus
270 End If
280 Set mControl = Nothing
290 Set mCommandBar = Nothing
300 End If
310 Exit Function
CreateTSEButton_Error:
Definitions ;
Private WithEvents objOLApp As Outlook.Application
Private WithEvents colInspectors As Outlook.Inspectors
Private WithEvents objExplorer As Outlook.Explorer
Private WithEvents mTSEButton As Office.CommandBarButton
References (image grab);
screen grab of the references list
I have done a lot of hunting around and a bunch of reading and from what I have seen Microsoft moved to a XML type model along the lines of CodeJock if that name rings a bell.
The code in the plugin is solid, I just cannot compile it due to the above error which if having to guess relates to the new XML format that should be used for 2013 onwards ?
I do have a couple of other VB6 apps here that use CodeJock for the Ribbon bar so they are self contained and work fine in VB6 so I can see what goes on there.
However tapping into Outlook and from the VB6 code and adding / interacting with a button in the Outlook Command bar or Ribbon bar as I think it is now called is not working for me.
My questions (or requests for help) fall around the following ( I'm not very clued up on Outlook interfacing );
a) has "Outlook.Explorer" been replaced with something else so it is just a matter of using what the new whatever is ? b) I have read about IDTExtensibility2 but not sure how that factors in if at all c) Do I actually have to rewrite the code completely for placing button on the Ribbon Bar / Command Bar of Outlook 2013 + and if so could you point me to an example please for VB6 and Outlook 2013 or 2016 etc as I am having trouble finding anything.
I would prefer not to have to rewrite this VB6 code in VB.Net if I can help it.
Thanks
Upvotes: 0
Views: 506
Reputation: 66286
You need to rewrite your code that accesses the command bars in Outlook with XML based ribbons. You'd be better off creating a new VSTO addin in VB.Net - that will let you use the built-in Ribbon designer.
Upvotes: 0
Reputation: 36
Note that there is no way to load a 32-bit DLL into a 64-bit process (and vice versa).
I'm pretty sure VB 6.0 runtime files are 32-bit. So your Outlook 2016 should be 32-bit as well. The reason it works okay with Outlook 2003 is because Outlook 2003 is a 32-bit application.
A possible solution would be either (1) or (2) as listed below:
Upvotes: 1