您当前的位置: 首页 > 办公软件教程 > Excel教程 浏览
使用CreateObject创建Excel实例代码
发布时间:2015-10-25    点击率:次    来源:www.sytcke.com    作者:电脑技术学习网

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

发表留言
发表留言请先登录!
免责声明:本站发布的信息和评论纯属网民个人行为,并不代表本站立场,如发现有违法信息或侵权行为,请直接与本站管理员联系,我们将在收到您的信息后24小时内作出处理!