0

I wrote some VBA in Excel 2013 which references Outlook and is now used on a virtual machine. My laptop was upgraded to Office 2016 last week, I made some changes in this tool and then it failed to run on the VM.

Turns out the VBA Outlook reference in the file changed to v16.0 (Office 2016) and so when the VM tried to run the code (on 2013), it couldn't find this reference.

There was also the generic Office reference which stayed as v15.0 though.

I haven't been able to find any documentation on this - is this standard behaviour and if so, any ideas on how I can make further changes to this file without the reference messing up every time?

1 Answer 1

0

This is standard behaviour.

You need to move from Early to Late binding. Remove the Outlook reference in VBE and declare the outlook application as Object in code.

Dim olApp As Object
Set olApp = CreateObject("Outlook.Application")

Bare in mind by doing so you will lose intellisense and you may have to change some constants to their numeric values, e.g. olMailItem to 0.

Make sure you have Option Explicit at the very top of your module(s), as this will highlight compilation errors.

Sign up to request clarification or add additional context in comments.

1 Comment

I have heard the terms "early binding" and "late binding" and never known what it related to or bothered to look it up - thanks! Problem solved and learned something new :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.