Microsoft Office Tutorials and References
In Depth Information
E.2.1.2 The GetObject function
Set XLApp = CreateObject("Excel.Application")
XLApp.Visible = True
Set wb = XLApp.Workbooks.Add
wb.SaveAs "d:\temp\SalesBook"
This code will run even more slowly than the previous code, which, in turn, is slower than the first
version.
Thus, we have three versions of Automation:
Using the New keyword syntax (requires an object library reference)
Using CreateObject and specific object variable declarations (requires an object
library reference)
Using CreateObject with generic As Object declarations (does not use an object
library reference)
These versions of automation are sometimes referred to by the names very early binding , early
binding , and late binding, respectively (although you may hear these terms used somewhat
differently).
These terms refer to the time at which VBA can associate (or bind ) the object, property, and
method names in our code to the actual addresses of these items. In very early binding, all
bindings are done at compile time by VBA—that is, before the program runs. In early binding,
some of the bindings are done at compile time and others are done at run time. In late binding, all
bindings are done at run time.
The issue is now evident. The more binding that needs to be done at run time, the more slowly the
program will run. Thus, very early binding is the most efficient, followed by early binding, and
then late binding.
Search JabSto ::




Custom Search