使用一些古老的代码尝试从Excel工作表中创建2018年ACAD奥运会的表格。
一切顺利进行,直到我试图创建一行并显示错误消息“Invalid procedure call or argument”
oDBxDoc。将创建oDbxDoc,并在“监视”窗口中显示它是有效的AxDbDocument。
在剥离AutoCAD 2017我的电脑之前,代码是有效的(我认为)...但是这个项目已经进行了几个月,我的记忆力越来越差。
我的测试模块代码0]
来自Ed Jobe(大约2006年)的类模块
- Option Explicit
- '=================================================================================================
- ' Purpose : Create an object class for access Autocad via the ObjectDBX
- '
- ' Date : 01/19/18
- ' Updated :
- '=================================================================================================
- ' Need code to differentiate the various versions of ACAD?
- ' 2018-01-19
- ' Replaced AXDBLib with AXDBLib
- '=================================================================================================
- ' References Requires
- ' AutoCAD C:\Program Files\Common Files\Autodesk Shared\acax22enu.tlb
- ' AXDBLib C:\Program Files\Common Files\Autodesk Shared\axdb22enu.tlb
- ' Scripting C:\Windows\SysWOW64\scrrun.dll
- '=================================================================================================
- 'copyright 2006, Ed Jobe
- ' Note: This requires ObjectDBX to be registered on each
- ' user's machine. This is done automatically on 2004 and up.
- ' In your AutoCAD folder, locate the file AxDb15.dll.
- ' This only needs to be done once at each machine. If you are using vb instead
- ' of vba, you will also need to set a reference to "ObjectDBX 1.0 Type library"
- ' and "Microsoft Scripting Runtime".
- ' This class auto-registers the dll, but here is the normal procedure---
- ' From the dos command line, type:
- ' C:\> cd Autodesk\Map200i
- ' C:\Autodesk\Map2000i> RegSvr32.exe AxDb15.dll
- 'This class unfortunately doesn't follow standards for objects due to the fact that
- 'I was unable to Implement the properties/methods of ObjectDbx. Normally, the Open,
- 'Close, Save and SaveAs methods would belong in the doc class. But since you can't use
- 'the Implements statement on ObjectDbx, I had to move them to this class. This class
- 'uses late binding to be able to handle versioning. In order to access all the
- 'methods/properties of an AxDbDocument in your project, you must Dim a variable as
- ' type AxDbDocument and then the object returned by the Doc property to cast it as
- ' an AxDbDocument object. Therefore, this class does not reference AxDb15.dll, so
- 'your project needs to.
- 'Last error number used: 1003
- 'Variable declarations for Properties
- Private oDoc As AxDbDocument ' Object
- Private strOrigPath As String
- Private strTempPath As String
- Private strExt As String
- Private bReadOnly As Boolean
- 'Property Declarations
- '*********************
- Public Property Get Doc() As Object
- Set Doc = oDoc
- End Property
- Public Property Get Ext() As String
- Ext = strExt
- End Property
- Public Property Get OrigPath() As String
- OrigPath = strOrigPath
- End Property
- Public Property Get TempPath() As String
- TempPath = strTempPath
- End Property
- Public Property Get ReadOnly() As Boolean
- ReadOnly = bReadOnly
- End Property
- 'Class Methods
- '*************
- Public Sub xClose()
- 'required for proper cleanup of temp files
- Set oDoc = Nothing
- End Sub
- Private Function acadVerNum() As String
- Dim verNum As String
- verNum = "HKEY_CLASSES_ROOT\AutoCAD.Drawing\CurVer"
-
- Dim wsh As Object
- ' Error trapping
- On Error GoTo ErrorHandler
-
- 'access Windows scripting
- Set wsh = CreateObject("WScript.Shell")
-
- 'read key from registry
- Dim resKey As String
- resKey = wsh.RegRead(verNum)
-
- acadVerNum = Right(resKey, 2)
-
- Set wsh = Nothing
- Exit Function
-
- ErrorHandler:
- acadVerNum = ""
- Set wsh = Nothing
-
- End Function
- Public Sub xOpen(FilePath As String)
- 'Sets the Doc property to an ObjectDBX Document
- 'late binding is used to avoid setting a reference.
- '
- On Error GoTo ErrHandler
-
- Dim dbxdoc As AxDbDocument 'Object
- Dim strTempName As String
- Dim fso As Scripting.FileSystemObject
- Dim fsoFile As Scripting.File
- Dim colPCs As AcadPlotConfigurations
- Dim objPC As AcadPlotConfiguration
- Dim varList As Variant
- Dim i As Integer
- Dim cnt As Integer
- Dim iActiveLayout As Integer
- Dim strObjDbxPath As String
- Dim ACAD As Object
-
- bReadOnly = False
- strOrigPath = FilePath
-
- Set fso = CreateObject("Scripting.FileSystemObject")
-
- Cleanup:
- 'if this is not the first time a doc was opened, then
|