Create VBA projects that are compatible with multiple computers.

Occasional Contributor

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.

1 Reply

@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.