怎样可以调用当前dwg文件中某个文本内的字符串给EXCEL呢?
<p>画图时一般都在图上固定地方表明 地址,联系人,电话等文本</p><p>我想把这些文本导入到EXCEL中A1,A2,A3行,VBA可以么?</p><p></p> <p>我已经可以反过来从excel中调用了!</p><p>Sub text()</p><p></p><p>Dim p(0 To 2) As Double '定义坐标变量</p><p></p><p><br/>ss$ = CStr(dydqxls)</p><p>MsgBox ss</p><p><br/>p(0) = 310.77: p(1) = 42: p(2) = 0 '坐标赋值</p><p><br/>Set txtobj = ThisDrawing.PaperSpace.AddMText(p, 50, ss)</p><p></p><p>End Sub</p><p></p><p><br/>Function dydqxls()</p><p></p><p><br/>Dim ExcelApp As Excel.Application</p><p></p><p>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/> a = ExcelApp.ActiveWorkbook.Sheets("数据输入").Range("b11").Value</p><p></p><p>dydqxls = a</p><p></p><p>End Function</p><p></p><p></p><p>大家试试看!</p> <p> Dim Ent As AcadEntity, TextEnt As AcadText<br/> Dim pp(0 To 2) As Double, TextToExcel As AcadText<br/> Set xlSheet = xlApp.sheets(1) 'excel通讯<br/> Dim ExcelRow<br/> ExcelRow = 2</p><p> For Each Ent In ThisDrawing.ModelSpace 循环实体<br/> Select Case Ent.ObjectName 获取实体名<br/> Case "AcDbText" 选择文本实体<br/> Set TextEnt = Ent<br/> xlSheet.cells(ExcelRow, 1).Value = TextEnt.InsertionPoint(0)<br/> xlSheet.cells(ExcelRow, 2) = TextEnt.InsertionPoint(1)<br/> xlSheet.cells(ExcelRow, 3) = TextEnt.InsertionPoint(2)<br/> xlSheet.cells(ExcelRow, 4) = TextEnt.TextString<br/> ExcelRow = ExcelRow + 1<br/> End Select<br/> Next Ent</p> <p>兰州人,感激不尽!</p><p>我事了一下,刚开始以为ACDBTEXT是错的,不过运行过程中发现CAD就是这么识别ENT的</p><p>请问比如ACDBTEXT ACDBMTEXT这些内部称呼在哪儿找着的呢?</p><p>明经上面没有发现呀!</p> yefeiwolaile发表于2007-10-24 22:33:00static/image/common/back.gif兰州人,感激不尽!我事了一下,刚开始以为ACDBTEXT是错的,不过运行过程中发现CAD就是这么识别ENT的请问比如ACDBTEXT ACDBMTEXT这些内部称呼在哪儿找着的呢?明经上面没有发现呀!dim EntText as acadtextdebug.print ent.objectname
页:
[1]