电脑教程
位置:首页>> 电脑教程>> office教程>> 使用CreateObject创建Excel实例代码

使用CreateObject创建Excel实例代码

  发布时间:2023-08-26 09:22:46 

标签:使用CreateObject创建Excel实例代码

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

0
投稿

猜你喜欢

手机版 电脑教程 asp之家 www.aspxhome.com