标签:cell 创建 ocx code ring 实例 ati 内容 close
1、createobject
所属库:VBA
所属类:Interaction
语法:Function Createobject(Calss AS String,[ServerName As String])
示例:
Sub demo_Excel_Word() Dim a As Object, d As Object ‘创建一个Word实例(Application对象)并赋值给变量a Set a = CreateObject("Word.Application") ‘通过a创建一个新的空白文档(Document对象),赋值给d。 Set d = a.documents.Add ‘让d的全部内容文字等于Excel工作表 A1 单元格中的内容 d.Range.Text = Worksheets(1).Cells(1, 1).Value ‘保存并关闭文档对象d d.SaveAs "d:\vbademo\demo_20_3.docx" d.Close ‘Application对象无法关闭,但可以将变量a设为Nothing以释放资源 Set a = Nothing End Sub
标签:cell 创建 ocx code ring 实例 ati 内容 close
原文地址:https://www.cnblogs.com/Aghanim/p/12306790.html