兰州人 发表于 2008-11-1 23:32:00

[原创]在excel的单元格中,获得圆的面积.

<p>在单元格中输入=ls()--------------- 采用的是excel的单元格自定义函数功能.<br/>自定义函数function ls() <br/>程序如下:</p><p>以下程序必须放在excel的bas模块中.<br/>Function ls() As Double<br/>&nbsp;&nbsp;Dim returnObj As AcadCircle<br/>&nbsp;&nbsp;Dim basePnt As Variant<br/><br/>&nbsp;&nbsp;With objModelDocument<br/>&nbsp; &nbsp;&nbsp;&nbsp;.Utility.GetEntity returnObj, basePnt, "选择一个圆"<br/>&nbsp; &nbsp;&nbsp;&nbsp;ls = returnObj.Area<br/>&nbsp;&nbsp;End With<br/>End Function<br/><br/>excel与autocad通讯程序如下 <br/><br/>Function objModelDocument() As AcadDocument<br/>&nbsp;&nbsp;Dim appAutoCad As AutoCAD.AcadApplication&nbsp;&nbsp;<br/>&nbsp;&nbsp;On Error Resume Next<br/>&nbsp;&nbsp;Set appAutoCad = GetObject(, "AutoCAD.Application")<br/>&nbsp;&nbsp;If Err Then<br/>&nbsp; &nbsp; Err.Clear<br/>&nbsp; &nbsp; Set appAutoCad = CreateObject("AutoCAD.Application")<br/>&nbsp;&nbsp;End If<br/>&nbsp;&nbsp;appAutoCad.Visible = True<br/>&nbsp;&nbsp;Dim AcadDoc As AcadDocument<br/>&nbsp;&nbsp;Set objModelDocument = appAutoCad.ActiveDocument<br/>End Function<br/></p>

johnsg 发表于 2008-11-5 16:47:00

可以用吗?
页: [1]
查看完整版本: [原创]在excel的单元格中,获得圆的面积.