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