What is early binding and late binding

BizBoy

Board Regular
Joined
Jul 26, 2012
Messages
118
Hi,
Can anyone please review below code and guide me if possible.
I have copied early binding instance from the code and tried to convert it to late binding.

Could you please confirm if am doing it correct way. Thanks.

Public X__App As Excel.Application
Public x__Wb As Workbook
Public x__ws As Worksheet

Sub Test()
'Ealry binding
Set X__App =CreateObject("Excel.Application")
Set x__Wb = X__App.Workbooks.Open(XX__PATH &"Test\Test.xlsb", False, True)

'Late Binding
Dim X__App As Object
Dim x__Wb As Object
Dim x__Wb As Object

Set X__App =CreateObject("Excel.application")
Set x__Wb = X__App.Workbooks.Open(XX__PATH &"Test\Test.xlsb", False, True)
Set x__ws = x__Wb.Worksheets("Test")
End Sub
 
Last edited:

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,692
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
The late binding is correct but you would of course need to remove the early bound Public variables.
 

BizBoy

Board Regular
Joined
Jul 26, 2012
Messages
118
Hi RoryA sir, yes, you are correct. These were kept just as a reference to post.
Have a nice day ahead.:)
 

BizBoy

Board Regular
Joined
Jul 26, 2012
Messages
118
Hi Experts,

I have a question. If I change a code from Early Binding to Late Binding, will there be any difference in the output.
If all the input parameters are same, will early or late binding affect the output in any way.

My guess is, it should not, however I am not sure, hence seeking help.
Can anyone please help me in this.
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,692
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
No, there should be no difference.
 

Watch MrExcel Video

Forum statistics

Threads
1,090,481
Messages
5,414,796
Members
403,544
Latest member
rabdorawsh

This Week's Hot Topics

Top