VBA - Shared file. Two users with different versions of Outlook

szita2000

Board Regular
Joined
Apr 25, 2012
Messages
101
Office Version
  1. 365
Platform
  1. Windows
Hi guys.

I created a file with rondebruin-s emailing code.
I have some issues as it is a shared file that two user uses, and I am getting reference errors

One of the user uses Microsoft Outlook 16.0 Object Library the other one uses 15.0.

Is there a way to code this so the reference will work correctly for both users?

Thanks
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
99% work on both (only a function created after 15.0 would not work on 15.0 and they are quite rare).
What is annoying is that the outlook object library has to be activated on each computer manually through VBA editor, which is a nightmare if people are not vba literate and computers not in the building. I remember I succeeded in activating them programmatically on opening file event by adapting a code like this one
Code:
[LEFT][COLOR=#333333][FONT=Verdana]Sub AddReference()[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]'Macro purpose:  To add a reference to the project using the GUID for the[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]'reference library[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]    Dim strGUID As String[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]    'Update the GUID you need below.[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]    strGUID = "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}"[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]    'Set to continue in case of error[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]    On Error Resume Next[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]    'Add the reference[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]    ThisWorkbook.VBProject.References.AddFromGuid _[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]        GUID:=strGUID, Major:=1, Minor:=0[/FONT][/COLOR]

[COLOR=#333333][FONT=Verdana]    'If an error was encountered, inform the user[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]    Select Case Err.Number[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]        Case Is = 32813[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]            'Reference already in use.  No action necessary[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]        Case Is = vbNullString[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]            'Reference added without issue[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]        Case Else[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]            'An unknown error was encountered, so alert the user[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]            MsgBox "A problem was encountered trying to" & vbNewLine _[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]            & "add or remove a reference in this file" & vbNewLine & "Please check the " _[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]            & "references in your VBA project!", vbCritical + vbOKOnly, "Error!"[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]    End Select[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]    On Error GoTo 0[/FONT][/COLOR]
[COLOR=#333333][FONT=Verdana]End Sub[/FONT][/COLOR][/LEFT]

and googling for GUID's code on one of my project.
 
Last edited:
Upvote 0
Thanks Kamolga I will try this.
Will report back on Tuesday to see if it was working.
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,593
Members
449,038
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top