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