Using the CreateObject Function to Create a Late-Bound Instance of Excel : Binding « Excel « VBA / Excel / Access / Word






Using the CreateObject Function to Create a Late-Bound Instance of Excel

 
Sub LateBinding()

    'Declare a generic object variable
    Dim objExcel As Object

    'Point the object variable at an Excel application object
    Set objExcel = CreateObject("Excel.Application")

    'Set properties and execute methods of the object
    With objExcel
        .Visible = True
        .Workbooks.Add
        .Range("A1") = "Hello World"
    End With

End Sub

 








Related examples in the same category

1.An Example of Early Binding
2.Late Binding
3.Early vs. Late Binding
4.After the reference is set, Word variables can be declared with the correct (Word) variable type.
5.creates a new instance of Word and then opens and makes visible an existing Word document:
6.Creating and Referencing Objects
7.If multiple versions of Word are installed, you can create an object for a specific version. The following statement, for example, uses Word 97.