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