使用CreateObject创建Excel实例代码

2024-04-08 151 0

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

相关文章

Switch怎样限制孩子下载的游戏类型
如何批量修改Word文档正文字体格式
win10设置新密码总是不符合
如何解决win10系统开机速度慢问题
win10休眠在哪里
win10如何更**辨率?