2
votes

I've already referred to this posting here about late bindings, but I'm not sure if it has answered my question. I'm forced to switch between XP's Office 2003 and Win 7's Office 2010 using Access VBA. If I edit in 2010, then 2003 cannot open the file because 'Fail to load .dll' and that has to do with my Microsoft Outlook 14.0 Object Library missing in Office 2003.

Is there any reason to have the object library even checked if I'm doing a late binding? Or does it still HAVE to be checked regardless and I'll always need to edit in 2003?

Thanks in advance!

1

1 Answers

5
votes

No, you don't need a Reference "ticked" in your VBA project if you are using late binding.

Often what I'll do is

  • build my code using early binding so IntelliSense will help me avoid typos and aid my memory re: method/property names, parameters, etc., then

  • convert my code to late binding once it has been (more or less) finalized

That's why in some of my sample code on here you'll see things like

Dim fso as Object  '' FileSystemObject
...
Set fso = CreateObject("Scripting.FileSystemObject")  '' New FileSystemObject

The items in the comments ('') are the original early binding declarations, then I replace them with the Object and CreateObject() calls (late binding) but leave the originals as comments in case I want to change them back.

And, as it seems you have discovered, I also have to remember to remove the references in the VBA project, otherwise it can cause problems on a different machine (and avoiding those problems is the whole point of late binding in these cases).