VBA to VB in AutoCAD LT???

Discussion in 'AutoCAD' started by u97pani, Jan 19, 2004.

  1. u97pani

    u97pani Guest

    Hi,
    How do you run a VBA transferred to VB from VB6 or similar with AutoCAD LT?

    I have a problem with setting up a VBA code(see code below) to VB and using it with AutoCAD 2002 LT. I have tested it with the full version of AutoCAD and it works fine. The error message I get with AutoCAD LT is: ActiveX can't create object.

    Is there something that can be done in the code below or are the settings
    on the computer wrong?

    I hope that someone can help me.

    Thanks, Ola


    Option Explicit

    Private Sub Command1_Click()

    On Error Resume Next

    Dim acadApp As AcadApplication
    Dim AcadDoc As AcadDocument
    Dim MySS As AcadSelectionSet
    Dim GrpC(0 To 1) As Integer
    Dim GrpV(0 To 1) As Variant
    Dim NewLine As AcadLine
    Dim Pt1 As Variant
    Dim Pt2 As Variant
    Dim newlayer As AcadLayer

    Set acadApp = GetObject(, "AutoCAD.Application")
    If Err Then
    Err.Clear
    Set acadApp = CreateObject("AutoCAD.application")
    If Err Then
    MsgBox Err.Description
    Exit Sub
    End If
    End If

    Set AcadDoc = acadApp.ActiveDocument

    MsgBox "Draw line."

    acadApp.Visible = True

    Set newlayer = AcadDoc.Layers.Add("TheLine" & 1)
    newlayer.Color = acRed
    AcadDoc.ActiveLayer = newlayer
    On Error GoTo errhnd
    Pt1 = AcadDoc.Utility.GetPoint(, "DrawLine")
    Pt2 = AcadDoc.Utility.GetPoint(Pt1, "DrawLine")
    Do Until Err.Number = -2145320928
    Set NewLine = AcadDoc.ModelSpace.AddLine(Pt1, Pt2)
    NewLine.Update
    Pt1 = Pt2
    Pt2 = AcadDoc.Utility.GetPoint(Pt1)
    Loop
    errhnd:

    End Sub
     
    u97pani, Jan 19, 2004
    #1
  2. u97pani

    keithwaite Guest

    keithwaite, Jan 20, 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.