bearv 发表于 2006-9-15 03:04:00

vb中创建CAD TOOLBAR出错,请高手指点

本帖最后由 作者 于 2006-9-16 2:01:38 编辑 <br /><br /> <P>CAD原代码</P>
<P>Private Sub AddToolbar()<BR>&nbsp;&nbsp;&nbsp; ' This example creates a new toolbar called TestToolbar and inserts a<BR>&nbsp;&nbsp;&nbsp; ' toolbar button into it. The toolbar is then displayed.<BR>&nbsp;&nbsp;&nbsp; ' To remove the toolbar after execution of this macro, use the Customize Menu<BR>&nbsp;&nbsp;&nbsp; ' option from the Tools menu.<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim currMenuGroup As AcadMenuGroup<BR>&nbsp;&nbsp;&nbsp; Set currMenuGroup = acadDoc.Application.MenuGroups.Item(0)&nbsp;&nbsp;'调试后此行出错<BR>&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp; ' Create the new toolbar<BR>&nbsp;&nbsp;&nbsp; Dim newToolBar As AcadToolbar<BR>&nbsp;&nbsp;&nbsp; Set newToolBar = currMenuGroup.Toolbars.Add("TestToolbar")<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' Add a button to the new toolbar<BR>&nbsp;&nbsp;&nbsp; Dim newButton As AcadToolbarItem<BR>&nbsp;&nbsp;&nbsp; Dim openMacro As String<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' Assign the macro string the VB equivalent of "ESC ESC _open "<BR>&nbsp;&nbsp;&nbsp; openMacro = Chr(3) &amp; Chr(3) &amp; Chr(95) &amp; "open" &amp; Chr(32)<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Set newButton = newToolBar.AddToolbarButton("", "NewButton", "Open a file.", openMacro)<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' Display the toolbar<BR>&nbsp;&nbsp;&nbsp; newToolBar.Visible = True</P>
<P>End Sub</P>
<P>在VB中运行后 提示 :</P>
<P>实时错误 ‘91’</P>
<P>对象变量或with块变量未设置</P>
<P>Set currMenuGroup = acadDoc.Application.MenuGroups.Item(0)&nbsp;&nbsp;'调试后此行出错<BR></P>
<P>问题已解决&nbsp; 谢谢</P>
<P>问题已解决&nbsp; 谢谢</P>
<P>问题已解决&nbsp; 谢谢</P>
<P>问题已解决&nbsp; 谢谢</P>
<P>问题已解决&nbsp; 谢谢</P>

wylong 发表于 2006-9-15 12:59:00

把acadDoc改为 thisdrawing 试试

bearv 发表于 2006-9-15 14:22:00

<P>晕~~~ 是在VB6.0里面啊 不是VBA</P>
<P>mccad 在吗?能指点一下吗?</P>
页: [1]
查看完整版本: vb中创建CAD TOOLBAR出错,请高手指点