Error 91 While Adding A Table

Error 91 While Adding A Table

samialtas
Explorer Explorer
998 Views
1 Reply
Message 1 of 2

Error 91 While Adding A Table

samialtas
Explorer
Explorer

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.

0 Likes
999 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor

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

0 Likes