zj-ο○oοo 发表于 2009-1-22 10:41:00

CAD中如何得到EXCEL 的RANGE对象啊?

本帖最后由 作者 于 2009-1-22 11:32:41 编辑 <br /><br /> <p>CAD中如何得到EXCEL 的RANGE对象啊?</p><p>cells.Range("a1:c2")<br/>已知cells对象</p><p>&nbsp;怎么得到这个范围对象啊。。。</p>

dianbotang 发表于 2009-3-25 16:52:00

<p><font size="2">打开vbe-工具-引用-Microsoft Excel 11.0 Object Library</font></p><p><font size="2">添加以下代码:</font></p><p>Private Sub GetRange()<br/>&nbsp;&nbsp;&nbsp; On Error Resume Next<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim excelApp As Excel.Application<br/>&nbsp;&nbsp;&nbsp; Set excelApp = GetObject(, "Excel.Application")<br/>&nbsp;&nbsp;&nbsp; If Err Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox Err.Description<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<br/>&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; excelApp.Visible = True<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim myRange As Range<br/>&nbsp;&nbsp;&nbsp; Set myRange = excelApp.ActiveSheet.Range("a1:c2")<br/>End Sub<br/></p><p>要求先打开excel。</p><p><font size="2"></font></p>
页: [1]
查看完整版本: CAD中如何得到EXCEL 的RANGE对象啊?