yefeiwolaile 发表于 2007-10-16 20:57:00

怎样可以调用当前dwg文件中某个文本内的字符串给EXCEL呢?

<p>画图时一般都在图上固定地方表明 地址,联系人,电话等文本</p><p>我想把这些文本导入到EXCEL中A1,A2,A3行,VBA可以么?</p><p></p>

yefeiwolaile 发表于 2007-10-18 22:41:00

<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>&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>End If</p><p><br/>&nbsp;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>

兰州人 发表于 2007-10-23 10:21:00

<p>&nbsp;Dim Ent As AcadEntity, TextEnt As AcadText<br/>&nbsp; Dim pp(0 To 2) As Double, TextToExcel As AcadText<br/>&nbsp; Set xlSheet = xlApp.sheets(1) 'excel通讯<br/>&nbsp; Dim ExcelRow<br/>&nbsp; ExcelRow = 2</p><p>&nbsp; For Each Ent In ThisDrawing.ModelSpace 循环实体<br/>&nbsp;&nbsp;&nbsp; Select Case Ent.ObjectName 获取实体名<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "AcDbText" 选择文本实体<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set TextEnt = Ent<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlSheet.cells(ExcelRow, 1).Value = TextEnt.InsertionPoint(0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlSheet.cells(ExcelRow, 2) = TextEnt.InsertionPoint(1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlSheet.cells(ExcelRow, 3) = TextEnt.InsertionPoint(2)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xlSheet.cells(ExcelRow, 4) = TextEnt.TextString<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ExcelRow = ExcelRow + 1<br/>&nbsp;&nbsp;&nbsp; End Select<br/>&nbsp; Next Ent</p>

yefeiwolaile 发表于 2007-10-24 22:33:00

<p>兰州人,感激不尽!</p><p>我事了一下,刚开始以为ACDBTEXT是错的,不过运行过程中发现CAD就是这么识别ENT的</p><p>请问比如ACDBTEXT ACDBMTEXT这些内部称呼在哪儿找着的呢?</p><p>明经上面没有发现呀!</p>

兰州人 发表于 2007-10-25 09:42:00

yefeiwolaile发表于2007-10-24 22:33:00static/image/common/back.gif兰州人,感激不尽!我事了一下,刚开始以为ACDBTEXT是错的,不过运行过程中发现CAD就是这么识别ENT的请问比如ACDBTEXT ACDBMTEXT这些内部称呼在哪儿找着的呢?明经上面没有发现呀!dim EntText as acadtextdebug.print ent.objectname
页: [1]
查看完整版本: 怎样可以调用当前dwg文件中某个文本内的字符串给EXCEL呢?