兰州人 发表于 2006-7-13 18:18:00

14.5 数据记录和AutoCAD实体调用

<P>如果将光盘中的数据记录和AutoCAD实体的对应.dvb文件,换个目录和mdb文件出现如下问题。</P>
<P></P>
<P>我分析出现的问题是VBE的问题。</P>
<P>翻译VBE的特性<BR>This property allows you to access the VBA IDE object model from AutoCAD's object model. The property will throw an exception if the VBAIDE is not available. For example, the VBAIDE is not available if the acvba.arx app has not been loaded. <BR>这个特性允许存取VBA IDE实体模式从AuotCAD实体模型中,.....,如果VBAID没有装载acvba.arx app, VBAIDE不可用。<BR><FONT color=#ff0000>因此,我认为出现图示问题是VBAID没有装载acvba.arx,如何解?<BR></FONT>Public Function OpenDB() As Boolean<BR>&nbsp;&nbsp;&nbsp; OpenDB = True<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 如果数据库已打开,不执行任何操作<BR>&nbsp;&nbsp;&nbsp; If adoCon.State &lt;&gt; 0 Then Exit Function<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; adoCon.CursorLocation = adUseClient<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 获得数据库文件的位置<BR>&nbsp;&nbsp;&nbsp; Dim strDbName As String<BR>&nbsp;&nbsp;&nbsp; Dim strProject As String</P>
<P>'出问题的语句<BR><FONT color=#ff3300>&nbsp;&nbsp;&nbsp; strProject = Left(ThisDrawing.Application.VBE.activevbProject.FileName, _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Len(ThisDrawing.Application.VBE.activevbProject.FileName) - 21)<BR></FONT>&nbsp;&nbsp;&nbsp; strDbName = strProject &amp; "sample.mdb"<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &amp; _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDbName &amp; ";"<BR>End Function<BR></P>

efan2000 发表于 2006-7-16 23:09:00

<P><FONT color=#ff3300>strProject = Left(ThisDrawing.Application.VBE.activevbProject.FileName, _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Len(ThisDrawing.Application.VBE.activevbProject.FileName) - 21)</FONT><BR>这句代码限定了工程文件的文件名必须大于21个字符,否则出错。</P>
<P>取工程文件的路径可以:</P>
<P>' 判断最后一个“\”的字符位置</P>
<P>Dim i As Integer<BR>i = InStrRev(ThisDrawing.Application.VBE.activevbProject.FileName, "\")<BR>If i &lt;&gt; 0 Then<BR>&nbsp;&nbsp;&nbsp; strProject = Left(ThisDrawing.Application.VBE.activevbProject.FileName, i)<BR>End If</P>
页: [1]
查看完整版本: 14.5 数据记录和AutoCAD实体调用