yao2001xp 发表于 2005-8-10 21:08:00

请教各位高手

<P>在excel 中aba编辑器先设置好:工具--引用--autocad 2000类型库后</P>
<P>在excel中定义了一个宏:</P>
<P>Public Sub drawautocadline()<BR>Dim autocadapplication As AutoCAD.acadApplication<BR>Dim startline(0 To 2) As Double<BR>Dim endline(0 To 2) As Double<BR>Set autocadapplication = CreateObject("autocad.acadapplication")<BR>startline(0) = Cells(2, 2).Value<BR>startline(1) = Cells(3, 2).Value<BR>endline(0) = Cells(2, 3).Value<BR>endline(1) = Cells(3, 3).Value<BR>autocadapplication.ActiveDocument.ModelSpace.AddLine startline, endline<BR>End Sub</P>
<P>运行时,弹出对话框,说activex不能创建部件对象,</P>
<P>将以上两处的autocad.acadapplication改为autocad.application也不行</P>
<P>不知什么原因,谢谢!<BR></P>

王咣生 发表于 2005-8-10 22:02:00

reply

Public Sub drawautocadline()<BR>&nbsp;&nbsp;&nbsp; Dim autocadapplication As AutoCAD.acadApplication<BR>&nbsp;&nbsp;&nbsp; Dim startline(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Dim endline(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; Set autocadapplication = CreateObject("<FONT color=#ff3300>autocad.application</FONT>") '还可以具体指定版本号如autocad.application.16<BR>&nbsp;&nbsp;&nbsp; startline(0) = Cells(2, 2).Value<BR>&nbsp;&nbsp;&nbsp; startline(1) = Cells(3, 2).Value<BR>&nbsp;&nbsp;&nbsp; endline(0) = Cells(2, 3).Value<BR>&nbsp;&nbsp;&nbsp; endline(1) = Cells(3, 3).Value<BR>&nbsp;&nbsp;&nbsp; autocadapplication.ActiveDocument.ModelSpace.AddLine startline, endline<BR>&nbsp;&nbsp;&nbsp; autocadapplication.Documents.Item (0)<BR>&nbsp;&nbsp;&nbsp; autocadapplication.Visible = True<BR>End Sub<BR>

yao2001xp 发表于 2005-8-11 11:18:00

<P>非常感谢王版!</P>
<P>&nbsp;</P>
页: [1]
查看完整版本: 请教各位高手