Early and Late Binding

To manipulate Maxsurf using VBA scripting in another application it is necessary to first create an instance of the Maxsurf Application object. This can be done using either Early Binding or Late Binding.

 

Binding refers to making a link between two programs. To be able to use Maxsurf from within Excel, we must create a link, referencing Maxsurf from Excel. When we bind Maxsurf to Excel, the functionality of Maxsurf becomes available in Excel.

Late binding uses the CreateObject method to create an instance of the Application object. For example, to create a new instance of the Maxsurf application object using late binding:

    Dim msApp As Object

    Set msApp = CreateObject("Maxsurf.Application")

However, when programming with VBA we recommend that you use Early Binding. It has many advantages over late binding in that the code will execute faster, coding errors will be detected at compile time and the Maxsurf object model will be incorporated into the intellisense features of the VB editor. To use early binding a reference to the Maxsurf object library must be added to your project. This is done using the Tools | References menu, which brings up the following dialog:

 

§    Scroll down the list of available references until you find the Maxsurf Object Library

§    Select this item by clicking in the box to it’s left

§    Click OK.

 

A new instance of Maxsurf can now be created using early binding:

Dim msApp as Maxsurf.Application
Set msApp = New Maxsurf.Application

or more simply using the line

Dim msApp as New Maxsurf.Application