guoning1973 发表于 2005-12-27 15:09:34

关于GetObject( , class )

大家能给解释一下GetObject(, class )这个函数吗?帮助不是很理解

ilovejolly 发表于 2005-12-27 16:05:43

理解OLE2 object吗?可以先去看看这个相关的资料,再来看函数就好理解了

guoning1973 发表于 2005-12-27 16:18:07

好的

guoning1973 发表于 2005-12-27 17:30:38

Sub Main
    Dim Result As Integer
    dim excel as Object
    dim book as Object
    dim worksheet as Object
    dim s_name as String
    dim s_pass as String
    dim count as Integer
    'Initially Recorded: 2005-8-29:36:33
    'Script Name: gn1
    Set excel = GetObject(,"Excel.application")
    if(excel Is Nothing) then
      Set excel = CreateObject("Excel.application")
      if(excel Is Nothing) then
            MsgBox "Couldn't find Excel!"
            Exit Sub
      End if
    End if
    Set book = excel.Workbooks.Open("test.xls")
    Set worksheet = book.Worksheets("test")
end sub
当我运行这段程序时,弹出提示信息(见附件),什么原因.错误出在"Set excel = GetObject(,"Excel.application")"

ilovejolly 发表于 2005-12-27 17:44:30

你首先要打开一个excel,你还是没明白帮助里的意思
页: [1]
查看完整版本: 关于GetObject( , class )