giswater 发表于 2006-1-7 18:58:00

[求助]未找到主键

<P>我的一些vba程序经常出现未找到主键错误,有谁遇到过,到底是什么原因!谢谢</P>

songzhi 发表于 2006-1-7 23:34:00

试举一例先

giswater 发表于 2006-1-8 09:46:00

<P>如下,更改特定文字的属性</P>
<P>Sub edittext()<BR>&nbsp; Dim txtmapgis As AcadText<BR>&nbsp; Dim valtextheight As Double<BR>&nbsp; Dim txtobject As AcadObject<BR>&nbsp; <BR>&nbsp; For Each txtobject In ThisDrawing.ModelSpace<BR>&nbsp;&nbsp;&nbsp; If txtobject.ObjectName = "AcDbText" Then<BR>&nbsp;&nbsp;&nbsp; Set txtmapgis = txtobject<BR>&nbsp;&nbsp;&nbsp; valtextheight = CDbl(txtmapgis.Height) * 0.5<BR>&nbsp;&nbsp;&nbsp; txtmapgis.Height = valtextheight<BR>&nbsp;&nbsp;&nbsp; 'Debug.Print valtextheight<BR>&nbsp;&nbsp;&nbsp; If txtmapgis.TextString = "设计" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtmapgis.color = acRed<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtmapgis.Rotation = -1.414<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtmapgis.StyleName = "ddd"&nbsp;&nbsp; ' ddd为自己新建的文字样式<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; txtmapgis.Update</P>
<P>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp; Next<BR>&nbsp;&nbsp;&nbsp; <BR>End Sub</P>

songzhi 发表于 2006-1-8 20:36:00

从这个程序上看好象是没有错误的,会不会文字样式在使用前没有创建呢?你不妨加入错误捕获的代码看看。
页: [1]
查看完整版本: [求助]未找到主键