Help with acad VBA

Discussion in 'AutoCAD' started by dc, Feb 10, 2004.

  1. dc

    dc Guest

    Hello Group
    ive been a cad user for a few years and now I'm trying to get my head around
    acad VBA.
    I have bought mastering AutoCAD VBA by Sybex.

    when I try to run listing 16.2 I get the following error

    Compile error: User-defined type not defined.

    the following is the code I am trying to run

    Option Explicit

    Public Sub DrawAutoCADLine()
    'sending line data to AutoCAD
    Dim AutoCADApplication As AutoCAD.Application
    Dim StartLine(0 To 2) As Double
    Dim EndLine(0 To 2) As Double
    Set AutoCADApplication = CreateObject("AutoCAD.Application")
    StartLine(0) = Cells(2, 2).Value
    StartLine(1) = Cells(3, 2).Value
    EndLine(0) = Cells(2, 3).Value
    EndLine(1) = Cells(3, 3).Value
    AutoCADApplication.ActiveDocument.ModelSpace.AddLine StartLine, EndLine
    End Sub

    is there something wrong with the code or am I doing something wrong myself
    ?

    TIA
    Dave
     
    dc, Feb 10, 2004
    #1
  2. dc

    Ben Guest

    Provided that 'Cells' is defined somewhere else, the following should be
    OK:

    Public Sub DrawAutoCADLine()
    'sending line data to AutoCAD
    Dim AutoCADApplication As Object
    ....

    Ben
     
    Ben, Feb 12, 2004
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.