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:

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,188
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,188
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
No, there should be no difference.
 

Forum statistics

Threads
1,078,486
Messages
5,340,620
Members
399,387
Latest member
amrita34

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top