乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 20|回复: 0

求助:帮忙修改一下cad中多段线坐标输出到excel

[复制链接]

3

主题

40

帖子

5

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
52
发表于 2012-3-6 18:42:00 | 显示全部楼层 |阅读模式
选择中的pl线,然后将x和y坐标输出到excel当前激活单元格位置。麻烦高手帮忙改改吧,非常感谢。
我根据网上的代码,修改了一下,可是偶尔可以运行成功。不知道问题出在哪里。
Sub a()
    '连接EXCEL——标准代码****************************
       Dim xlApp As Excel.Application
       Dim xlbook As Excel.Workbook
       Dim xlSheet As Excel.Worksheet
       On Error Resume Next
       Set xlApp = GetObject(, "excel.application")
       If Err  0 Then
         Err.Clear
         Set xlApp = CreateObject("excel.application")
         If Err  0 Then
           MsgBox "无法启动excel"
           Exit Sub
         End If
       End If
       If ActiveWorkbook.Sheets.Count = 0 Then xlbook = xlApp.Workbooks.Add
       Set xlbook = xlApp.ActiveWorkbook
       Set xlSheet = xlbook.ActiveSheet
        xlApp.Visible = True
        If Err  0 Then Err.Clear
    '标准代码结束*****************************************
Dim retCoord() As Double
Dim a As AcadLWPolyline
Dim i As Integer
Dim j As Integer
Dim l As Integer
i = 0
ThisDrawing.Utility.GetEntity a, "Select an object"
    retCoord() = a.Coordinates
On Error GoTo e
Do While CBool(retCoord(i))  False
j = ActiveCell.Row  '这个无法返回激活单元格地址
l = ActiveCell.Column
xlSheet.Cells(j + i / 2, l).Value = retCoord(i)   
xlSheet.Cells(j + i / 2, l + 1).Value = retCoord(i + 1)
i = i + 2
Loop
e: Exit Sub
j = 0
l = 0
End Sub
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-6-30 11:03 , Processed in 1.828102 second(s), 54 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表