首页 excel技巧 使用CreateObject创建Excel实例代码

使用CreateObject创建Excel实例代码

发布:2023-08-06 18:14:31 阅读:198

一、使用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属性等。

上一篇:Excel设置万位分割符的方法 下一篇:Excel不能保存格式
相关文章 查看更多