cad抓點傳回excel
2 posters
cad抓點傳回excel
各位高手請問下列程式哪裏錯了,以前excel2003還以使用,現在灌2016excel,就不行了,是不是這個原因呢?,如何修改程式呢?
'勾選-一直抓點傳回excel
Sub sendPt2Excel()
Dim excelapp As Excel.Application
Dim wkobj As Workbook
Dim shtobj As Worksheets
On Error Resume Next
Set excelapp = GetObject(, "Excel.Application")
Set excASH = excelapp.ActiveSheet
If Err <> 0 Then
Err.Clear
MsgBox "請執行MicroSoft Excel...", 0, Err
End
End If
Set cadOBJ = ThisDrawing.Utility
Dim pt1 As Variant '抓點x,y,z
Dim i As Integer
'MsgBox excASH.Cells(1, 1), vbOKOnly, "顯示儲存格a1"
'excASH.Cells(1, 2) = "AutoCAD" '將儲存格b1填入AutoCAD
'開始
cadOBJ.Prompt "請由畫面點選一點後回傳至Excel" & vbCrLf '在畫面顯示說明行
i = 1
excASH.Cells(i, 1) = "X"
excASH.Cells(i, 2) = "Y"
excASH.Cells(i, 3) = "Z"
Err.Clear
Do While Err = 0
i = i + 1
cadOBJ.Prompt "第" & i & "點:"
pt1 = returnPnt '抓點
If Err <> 0 Then Exit Do '按取消時
excASH.Cells(i, 1) = pt1(0)
excASH.Cells(i, 2) = pt1(1)
excASH.Cells(i, 3) = pt1(2)
Loop
MsgBox "ok"
End Sub
'抓點
Private Function returnPnt() As Variant
returnPnt = ThisDrawing.Utility.GetPoint
End Function
'勾選-一直抓點傳回excel
Sub sendPt2Excel()
Dim excelapp As Excel.Application
Dim wkobj As Workbook
Dim shtobj As Worksheets
On Error Resume Next
Set excelapp = GetObject(, "Excel.Application")
Set excASH = excelapp.ActiveSheet
If Err <> 0 Then
Err.Clear
MsgBox "請執行MicroSoft Excel...", 0, Err
End
End If
Set cadOBJ = ThisDrawing.Utility
Dim pt1 As Variant '抓點x,y,z
Dim i As Integer
'MsgBox excASH.Cells(1, 1), vbOKOnly, "顯示儲存格a1"
'excASH.Cells(1, 2) = "AutoCAD" '將儲存格b1填入AutoCAD
'開始
cadOBJ.Prompt "請由畫面點選一點後回傳至Excel" & vbCrLf '在畫面顯示說明行
i = 1
excASH.Cells(i, 1) = "X"
excASH.Cells(i, 2) = "Y"
excASH.Cells(i, 3) = "Z"
Err.Clear
Do While Err = 0
i = i + 1
cadOBJ.Prompt "第" & i & "點:"
pt1 = returnPnt '抓點
If Err <> 0 Then Exit Do '按取消時
excASH.Cells(i, 1) = pt1(0)
excASH.Cells(i, 2) = pt1(1)
excASH.Cells(i, 3) = pt1(2)
Loop
MsgBox "ok"
End Sub
'抓點
Private Function returnPnt() As Variant
returnPnt = ThisDrawing.Utility.GetPoint
End Function
c3883882004- 新手(尚未報到升等一般會員)
- 文章總數 : 1
年齡 : 48
來自 : 高雄
職業 : 待業
愛好 : 看書
個性 : 內向
使用年資 : 新手
使用版本 : 新手
經驗值 : 4704
威望值 : 0
注冊日期 : 2012-01-13
回復: cad抓點傳回excel
您好:
請先完成升等手續後,再到論壇「進階討論區」發表主題,這樣比較方便討論,也可以得到完整的幫助!
升等方式說明: https://www.autocad-tw.com/t1685-topic
▼進階討論區
https://www.autocad-tw.com/f38-forum
[新手請進]升等辦法:完成一篇報到文章,立即升等一般會員!!
https://www.autocad-tw.com/t1685-topic
謝謝配合~
請先完成升等手續後,再到論壇「進階討論區」發表主題,這樣比較方便討論,也可以得到完整的幫助!
升等方式說明: https://www.autocad-tw.com/t1685-topic
▼進階討論區
https://www.autocad-tw.com/f38-forum
[新手請進]升等辦法:完成一篇報到文章,立即升等一般會員!!
https://www.autocad-tw.com/t1685-topic
謝謝配合~
____________________________________________________________________________________
👉快速比例設定與出圖技巧-線上課程(點我)👈
這個論壇的權限:
您 無法 在這個版面回復文章