VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error 91 While Adding A Table

1 REPLY 1
Reply
Message 1 of 2
samialtas
919 Views, 1 Reply

Error 91 While Adding A Table

I gave a try to this code found on https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-ActiveX/files...

 

Sub Example_AddTable()
    ' This example adds a table in model space

    Dim MyModelSpace As AcadModelSpace
    Set MyModelSpace = ThisDrawing.ModelSpace
    Dim pt(2) As Double
    Dim MyTable As AcadTable
    Set MyTable = MyModelSpace.AddTable(pt, 5, 5, 10, 30)
    ZoomExtents

End Sub

And when I run it, it throws Error 91. I declared pt coordinates which means evertyhing seems OK in order for the code to work.

 

Please help.

1 REPLY 1
Message 2 of 2
norman.yuan
in reply to: samialtas

The error is because you DID NOT supply an valid point coordinate in the form of Double array. That is, the code declares an variable pt as an array of Double, but does not fill the 3 elements of the array with values, thus, pt is an EMPTY array.

 

To correct your code, you need to specify a valid point coordinate:

 

Dim pt(2) As Double

pt(0) = 0.0 : pt(1) = 0.0 : pt(2) = 0.0  '' assume you insert the table at (0, 0, 0)

...

Norman Yuan

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report