yefeiwolaile 发表于 2007-10-25 21:45:00

[求助]写MTEXT时自动捕捉插入点和手写输入插入点难道不同?

<p>Sub cadtoxls()</p><p>&nbsp; Dim ExcelApp As Excel.Application<br/>&nbsp;&nbsp;&nbsp; On Error Resume Next</p><p>&nbsp;&nbsp;&nbsp;&nbsp; Set ExcelApp = GetObject(, "Excel.Application")</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If Err &lt;&gt; 0 Then</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set ExcelApp = CreateObject("Excel.Applicationn")</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If</p><p><br/>&nbsp;&nbsp;&nbsp;&nbsp; Set xlsheet = ExcelApp.ActiveWorkbook.Sheets("数据输入") 'excel通讯<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;Dim Ent As AcadEntity, TextEnt As AcadMText<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;' Dim TextToExcel As AcadMText<br/>&nbsp;<br/>Dim pp As Variant</p><p>&nbsp; <br/>&nbsp; Dim p(0 To 2) As Double '定义坐标变量</p><p>Dim p2(0 To 2) As Double</p><p>Dim p3(0 To 2) As Double</p><p>Dim p4(0 To 2) As Double</p><p><br/>p(0) = 310.77: p(1) = 42: p(2) = 0 '坐标赋值</p><p>p2(0) = 353.56: p2(1) = 42: p2(2) = 0</p><p>p3(0) = 336.33: p3(1) = 10.44: p3(2) = 0</p><p>p4(0) = 367.08: p4(1) = 17.98: p4(2) = 0<br/>&nbsp; </p><p>&nbsp; For Each Ent In ThisDrawing.PaperSpace '循环实体<br/>&nbsp;&nbsp;&nbsp; Select Case Ent.ObjectName '获取实体名<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "AcDbMText" '选择文本实体<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set TextEnt = Ent<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pp = TextEnt.InsertionPoint<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If pp(0) = p(0) And pp(1) = p(1) Then<br/>&nbsp;&nbsp;&nbsp; </p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dz1 = TextEnt.TextString<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf pp(0) = p2(0) And pp(1) = p2(1) Then</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bb = TextEnt.TextString<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For aa = 1 To Len(bb)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If IsNumeric(Mid(bb, aa, 1)) Then Exit For</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next aa</p><p><br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf pp(0) = p3(0) And pp(1) = p3(1) Then<br/>&nbsp;&nbsp;&nbsp; </p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xz1 = TextEnt.TextString</p><p><br/>&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; </p><p>&nbsp;&nbsp;&nbsp; End Select<br/>&nbsp;<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp; Next Ent</p><p>&nbsp;mz1 = CStr(Left(bb, aa - 1))</p><p>&nbsp;hm1 = CStr(Right(bb, Len(bb) - aa + 1))<br/>&nbsp;<br/>&nbsp;<br/>&nbsp;<br/>&nbsp; dzxz1 = dz1 &amp; xz1</p><p><br/>xlsheet.Cells(1, 2) = mz1<br/>xlsheet.Cells(5, 2) = dzxz1<br/>xlsheet.Cells(15, 2) = hm1</p><p><br/>&nbsp;End Sub</p><p>请问为什么我在&nbsp; P&nbsp; 点写MTEXT时,用自动捕捉插入点时,dz1显示不出来</p><p>而用手写输入插入点310.77,42,0&nbsp; dz1却可以识别呢?</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
页: [1]
查看完整版本: [求助]写MTEXT时自动捕捉插入点和手写输入插入点难道不同?