liuyang4740 发表于 2009-1-14 12:19:00

vba窗体问题

本帖最后由 作者 于 2009-1-14 12:31:26 编辑 <br /><br /> <p>想弄一个窗体,窗体上摆一些控件,当我选择"执行"控件时候,提示错误:自动化(automation)错误</p><p>远程进程到类型库或对象库的连接丢失。&nbsp; 请教高手如何处理</p><p>源码如下:Private Sub cmd1_Click()<br/>&nbsp;<br/>&nbsp; Dim ssetobj As AcadSelectionSet<br/>&nbsp;&nbsp; Form1.Hide<br/>&nbsp;&nbsp; For i = 0 To ThisDrawing.SelectionSets.Count - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set ssetobj = ThisDrawing.SelectionSets.Item(i)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If ssetobj.Name = "au100" Then ssetobj.Delete<br/>&nbsp;&nbsp;&nbsp; Next i<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set ssetobj = ThisDrawing.SelectionSets.add(SsetName)<br/>&nbsp;&nbsp; '让用户在屏幕上选择要加入选择集的图元<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ssetobj.SelectOnScreen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '运行到这步出错!!!!<br/>&nbsp;&nbsp;&nbsp;&nbsp; '遍历选择集合<br/>&nbsp;&nbsp;&nbsp;&nbsp; End Sub<br/></p>

dbczhaoy 发表于 2009-1-14 12:59:00

<p>Dim sset As AcadSelectionSet<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If AutoCADapp.ActiveDocument.SelectionSets.Count = 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set sset = AutoCADapp.ActiveDocument.SelectionSets.add("sset ")<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set sset = AutoCADapp.ActiveDocument.SelectionSets(0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sset .Clear<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If</p><p>sset_text.Select ....</p><p>试下看</p>

liuyang4740 发表于 2009-1-14 13:11:00

多谢楼上的,还是不行啊

fjfhgdwfn 发表于 2009-1-14 15:15:00

<p>dim SsetName as string</p><p>ssetname="TT"</p><p></p><p>再试了。应是这个变量是空的过</p>

liuyang4740 发表于 2009-1-14 19:17:00

<p>对啊,多谢楼上的!</p>

qihuiqiang 发表于 2009-1-17 09:23:00

<p>应该是类型库问题。 工具 》引用 错误的类型库去掉即可</p>
页: [1]
查看完整版本: vba窗体问题