How to use Early and Late Binding the right way!

preview_player
Показать описание
👉 Ready to master VBA?
(Note: If the download page doesn't work then make sure to turn off any popup blockers)

VBA Early vs Late Binding(and how to easily switch between them)

In this video I cover how to use binding. We look at the two types of binding with code examples of each.
Then we look at the pros of each. We so how to use compiler parameters to switch between. Finally we see an elegant solution that allows you to easily switch between each method.

#ExcelVBABinding #VBALateBinding #VBAEarlyBinding


Useful VBA Shortcut Keys
========================

Debugging:
Compile the code: Alt + D + L OR Alt + D + Enter
Run the code from the current sub: F5
Step into the code line by line: F8
Add a breakpoint to pause the code: F9(or click left margin)

Windows:
View the Immediate Window: Ctrl + G
View the Watch Window: Alt + V + H
View the Properties Window: F4
Switch between Excel and the VBA Editor: Alt + F11
View the Project Explorer Window: Ctrl + R

Writing Code:
Search keyword under cursor: Ctrl + F3
Search the word last searched for: F3
Auto complete word: Ctrl + Space
Get the definition of the item under the cursor: Shift + F2
Go to the last cursor position: Ctrl + Shift + F2
Get the current region on a worksheet: Ctrl + Shift + 8(or Ctrl + *)
To move lines of code to the right(Indent): Tab
To move lines of code to the left(Outdent): Shift + Tab
Delete a Line: Ctrl + Y(note: this clears the clipboard)

Table of Contents:

00:00 - Introduction
00:28 - What is binding?
00:49 - Examples of binding
02:41 - Late Binding vs Early Binding
03:34 - When to use each type
03:57 - Binding rule of thumb
04:08 - Using a Basic If Statement
05:03 - How to switch between
06:31 - Possible solutions
07:39 - My simple method
08:29 - Class Modules
Рекомендации по теме
Комментарии
Автор

Excellent! Oh, I wish I knew this a long time ago. Proof that it’s never too later to learn. Thanks, Paul

jimfitch
Автор

This was a better explanation than several webpages I reviewed. THANK YOU.

netizencapet
Автор

And this is why I always use late binding. The problems from users having different versions of the DLLs are just not worth the pros of early binding. Also, as we get more experienced, we can live well without it.
Great explanation of the pros/cons and possible workarounds to still use early binding.

pbs
Автор

If I just have watched this video 2 months ago... I'd saved a lot of time

julioccorderoc
Автор

I've dabbled with early and late binding in a large MS Access application, but always found it cumbersome to switch between the two methods. Your solution with conditional compilation is a game changer. Thanks very much

jacksonmacd
Автор

Thanks for your sharing. Now I understand more deeply about early & late binding.

trantuananh
Автор

Wow, excellent, I have been waiting this video for a long time, you have changed my approach to any VBA project I will work in

gameon
Автор

Really brilliant approach for late and early binding!
Just a comment regarding the scripting runtime library: As this library has not changed for ages I think it does not do any harm if you always use early binding in this case.
Another comment: The library you use has to be installed on the target system regardless of one uses early or late binding.

guwu
Автор

You solved so many problems for me in 10 minutes 🎉

brettnelson
Автор

Another great lesson and video! Thanks Paul! Thumbs up!!

wayneedmondson
Автор

Clever and smart! I like it very much!👍👍👍
Thanks Paul!😁💚🍀🤟😎

johnwayne
Автор

Oh Paul, that's a great solution!

SolutionsByPVV
Автор

Thank you Mr. Paul for the nice video.
Why don't you create a complete VBA course on Udemy?

hammeedabdo.
Автор

Ha! Just last week I was trying to debug some old access code and couldn't figure our what was up with a DLL error. This video would have been so convenient.

MeTalkPrettyOneDay
Автор

I always use late binding. No exceptions. My VBA code is always usable.

averagebodybuilder
Автор

If we don't want to implement a way to change to late binding before providing the .xlsm to another person, what exactly is the restriction to communicate to the other person so they don't have a DLL issue?

CaseNav
Автор

Tempts me to come our of retirement and get back into the game....not really. A really useful video as per usual Cheers

peterwooldridge
Автор

Hey Paul, Big fan of your work. Just a small feedback, your download link is not working for me and this is not first video. it's happening on all of your videos. I am using Edge.

vkpunique
Автор

Masterfull as always. I needed this video 5 years ago. I always used late binding and haven’t intellisense really slow you down. Will the code still working with the external library enums? I. E. acFormatXLS12 ? I usually have to convert them to their actual value, I. E. Instead of acFormatXLS12, I had to use 8 for example when I use late binding.

urielramirez
Автор

In suppose throughout any code, we need to check if the another application is open or closed how can we do that (not using API and I am using sendkeys). I don't want to set everywhere if else statements...

OmkarUmbre