PDA

View Full Version : Alternative to late Binding?



rocheey
05-04-2008, 09:11 AM
Greetings, all, new guy here. I found this place quite by accident and Im glad I did! Anyhoo, heres my situation:

Developing some code in another MS-Office compatible app to open excel using OLE, and write some cells. However, Im the only one in the office with the new 2007, while everyone else is running 2003.

There has gotta be another alternative to using early binding: the code developement and execution times are so much slower using early binding, and I know there will be many code changes to come. Is there a third alternative? Some sort of 'load library' call where I can conditionally load the binaries?

Since Im the only user NOT using the same version app, would it be possible to even grab the .tlb from the earlier version of excel and point my references there?

Or perhaps something else id not even considered ?

Ken Puls
05-04-2008, 02:00 PM
Hi there, and welcome to VBAX.

Personally I haven't found too much noticeable difference in execution speed with early vs late binding, but then it may depend on just how much you are doing with it.

With regards to devleopment time being slower using late binding, why develop in that manner? A good friend of mine once told me to always develop early, release late. This way you get all the access to the intellisense and such for development and tesitng, and then you convert it to a late bound model for release to the wild. At that point the references to the app versions are a non issue.

A third option though, if you really want to go there, is to leverage some code to strip the references and re-reference at opening. You can find some KB entries to do this here:
Remove Missing VBA Library References via code
Add a VBA Reference Library via code
Determine the File Path or GUID to a VBA Reference Library

rocheey
05-05-2008, 03:03 PM
and thats definitely going into the library.... but I should rethink the 'develop early / release late' ... which begs the other question - (you probably seen this comin'...) .. is there VBE routines to find/replace code, so I can replace the app-specific objects with generic objects?

xld
05-05-2008, 04:05 PM
Do it with conditional compilation.

Ken Puls
05-05-2008, 09:14 PM
and thats definitely going into the library.... but I should rethink the 'develop early / release late' ... which begs the other question - (you probably seen this comin'...) .. is there VBE routines to find/replace code, so I can replace the app-specific objects with generic objects?

Honestly, I just use the find/replace feature in the VBE to do this.


Do it with conditional compilation.

That would be an alternative, for sure. Bob, you should put up an example of this on your site. :yes

xld
05-06-2008, 12:20 AM
That would be an alternative, for sure. Bob, you should put up an example of this on your site. :yes

Good idea, I will get onto it this week.

Ken Puls
05-06-2008, 10:31 PM
Good idea, I will get onto it this week.

Excellent. Looking forward to reading it. :yes