I created a program on my work computer which runs Microsoft Office 2016 however, my colleague cannot use the VBA program because it doesn't have the updated object library. Specifically, the Date and Left function prevent the program from working.
If they are running a 2010 version of Microsoft Office, is it possible to update their Object Libraries?
You can't use references to newer libary version using an older version as it can provide functions that the older version don't have, just the other way around it could work (old reference with new libary as they are usually backward compatible).
If one reference is broken, all other are not loaded too. That's why the VBA
functions Date
and Left
fail as the libary is not loaded.
To get independent of the Office
version use Late-Binding, but even then you can't use new functions on old versions (just use the subset of the oldest version you want to support or check for version and if the it is too old display a message that the faeture that uses the function is not availible for this Office
version).
You can develop Early-Bound
to have Intellisense
and object browser and switch to Late-Bound
before distributing.
- Remove the reference(s) in VBA -> Tools
- Change class declarations to
Object
- Create instance with
CreateObject
- Replace enums with your own enum, with their integer value or with a constant
Example:
Dim OutlookInstance as Outlook.Application
Dim OlMailItem as Outlook.Mailitem
Set OutlookInstance = New Outlook.Application
Set OlMailItem = OutlookInstance.CreateItem(olMailItem)
changes to:
Dim OutlookInstance as Object
Dim OlMailItem as Object
Set OutlookInstance = CreateObject("Outlook.Application")
Set OlMailItem = OutlookInstance.CreateItem(0)
You can download a module with enums for Outlook 2013
at Codekabinet (not tested, but they should cover most of Outlook 2016
) and import to your project or get the values while you are Early-Bound
from object-browser or just google.