一、使用CreateObject创建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
二、使用CreateObject创建指定版本的Excel实例
Sub mate()
Dim objExcel As Object
Set objExcel = CreateObject("Excel.Application.8")
End Sub
当Create对象实例之后,就可以使用该对象的所有属性和方法了,如SaveAs方法、Open方法、Application属性等。
新闻热点
疑难解答