Forum Discussion

hoacvxd's avatar
hoacvxd
Copper Contributor
Sep 22, 2022

Create VBA projects that are compatible with multiple computers.

I have a small project written in VBA and has a reference to the Microsoft Office16.0 Object Library. It works on my computer (Installed Office 365) but when deploying to another computer with Office 2010 installed, it gives error some simple functions like Left, Right , ThisWorkbook...
How can I know which version of Microsoft Office is installed on another computer and automatically refer to the libraries available on that computer:
Microsoft Office Object Library.
Microsoft Excel Object Library.
Microsoft Word Object Library.

  • hoacvxd 

    Although it's possible to set a reference programmatically, it is very tricky - I wouldn't recommend it.

    It would be easier to use late binding: remove the reference to the Microsoft Office16.0 Object Library, and replace constants from that library with their values.

    After you remove the reference, select Debug > Compile <projectname>.

    See which errors you get and fix them one by one.

Resources