如下程序:
Sub OutEx()
Dim Ex As Excel.Application Dim ExWorkBook As Workbook Dim ExSheet As Worksheet On Error Resume Next Set Ex = GetObject(, "Excel.Application") If Err <> 0 Then Err.Clear Set Ex = CreateObject("Excel.Application") If Err <> 0 Then Err.Clear MsgBox "建立Excel应用出错!" Exit Sub End If End If Set ExWorkBook = Ex.Workbooks.Add Set ExSheet = ExWorkBook.ActiveSheet Ex.Visible = True
End Sub
执行到红色部分,出现以下错误:
运行时错误“91”:
对象变量或With块变量未设置
程序已经引用了Microsoft Excel 11.0 Object Library
大家帮忙解决以下呀!分析下什么问题? |