乐筑天下

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

Excel VBA -在Autocad中创建表格-错误91 -帮助?

[复制链接]

11

主题

40

帖子

3

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
83
发表于 2013-12-27 13:28:21 | 显示全部楼层 |阅读模式
应用程序参数:
Autocad 2013,64位
Excel 2010,32位
错误
:背景:
我有一个例程(基于从网络上获得的代码(大部分来自Fixo)),该例程从Excel打开ACAD并将工作表值复制到新创建的AutoCAD图形中的表中。
当我尝试创建一个表时,继续得到错误代码91。  表已创建,但程序将退出到错误处理程序。 错误处理程序将换出以继续下一步,程序将继续,但不更新表值。
在创建表格之前,我将尝试创建一个表格样式,但现在我正在向真正知道自己在做什么的人寻求帮助。
我知道 Dot.Net 将是最佳解决方案,但是VSTO对于一个在一旁做这件事的人来说有一个非常陡峭的学习曲线,即工作但不是在工作时间。
Excel VBA 代码:
  1. ' Sub to create drawing with submittal text
  2. Sub ACADtxt(DataSheet As Worksheet) '
  3. Dim RowCount As Integer, iCount As Integer
  4. Dim tmpStr1 As String, tmpStr2 As String
  5. Dim FileName As String
  6. Dim acad As AcadApplication
  7. Dim adoc As AcadDocument
  8. Dim aspace As AcadBlock
  9. Dim Alayer As AcadLayer
  10. Dim entArray() As AcadEntity
  11. Dim ListTable As acadTable
  12. 'Dim insPt(2) As Double
  13. Dim insPt As Variant
  14. On Error GoTo ErrorHandler
  15. Dim appNum As String
  16. appNum = acadVerNum
  17. ' See if ACAD is on the computer
  18. If appNum = "" Then
  19.     MsgBox "Sorry, but AutoCAD does not appear to be on this computer.", vbExclamation
  20.     Exit Sub
  21. End If
  22. ' Start ACAD
  23. Set acad = CreateObject("Autocad.Application." & appNum)
  24. Set adoc = acad.ActiveDocument
  25. Set aspace = adoc.ActiveLayout.Block
  26. acad.Visible = True
  27. ' Create layers Text1 and Text2
  28. Call MakeSetLayer("Text1", 11)
  29. Call MakeSetLayer("Text2", 12)
  30. ' Now load the marked cells with the appropriate drawing # and title
  31. DataSheet.Activate
  32. ' See how many rows we need to check
  33. With ActiveSheet
  34.         RowCount = .Range("A" & .Rows.Count).End(xlUp).row
  35. End With
  36. insPt = adoc.Utility.GetPoint(, vbCrLf & "Pick the upper left point of table:")
  37. ' Create the table
  38. ListTable = adoc.ModelSpace.AddTable(insPt, RowCount, 2, 3.5, 20#) '  0 Then
  39.         'MsgBox Err.Description
  40.         Stop
  41.     End If
  42. End Sub

更正了我的错误...
修订。。。
  1. ListTable = adoc.ModelSpace.AddTable(insPt, RowCount, 2, 3.5, 20#) '  0 Then
  2.         MsgBox Err.Description
  3.         Stop
  4.     End If
  5. End Sub
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-4-21 02:48 , Processed in 0.583896 second(s), 65 queries .

© 2020-2025 乐筑天下

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