+ Reply to Thread
Results 1 to 2 of 2

Excel 2010 vba autocad

  1. #1
    Registered User
    Join Date
    04-30-2009
    Location
    tokyo
    MS-Off Ver
    Excel 2016
    Posts
    43

    Excel 2010 vba autocad

    Hello,

    I am in Excel 2010 VBA editor and I am trying to run the routine shown below.
    For some reason these two lines don't work.

    Dim mylineobject As AcadLine
    Dim CircleObj As AcadCircle

    Any ideas?

    Thanks

    Kato01

    Public Sub test()

    '=======================================
    A$ = "########0.0"
    On Error Resume Next
    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
    acadApp.Visible = True ' AUTOCAD
    acadApp.Top = 0
    acadApp.Left = 0
    acadApp.Width = 1024
    acadApp.Height = 740
    Set ObjAcad = GetObject(, "Autocad.Application")
    ObjAcad.Visible = True
    Set AcadDoc = acadApp.ActiveDocument
    Set AcadUtil = AcadDoc.Utility
    activeDoc.ActiveSpace = acModelSpace
    '=================================================
    Dim mylineobject As AcadLine '<============== problem 1
    Dim CircleObj As AcadCircle '<============== problem 2
    Dim startpoint(0 To 2) As Double
    Dim endpoint(0 To 2) As Double
    Dim CircleCenter(0 To 2) As Double
    'FIRST LINE
    startpoint(0) = 0
    startpoint(1) = 0
    startpoint(2) = 0
    endpoint(0) = 1
    endpoint(1) = 0
    endpoint(2) = 0

    'SECOND LINE
    startpoint(0) = 0.5
    startpoint(1) = -0.5
    startpoint(2) = 0
    endpoint(0) = 1
    endpoint(1) = 0
    endpoint(2) = 0

    Set mylineobject = ThisDrawing.ModelSpace.AddLine(startpoint, endpoint)

    '=========

    CircleCenter(0) = 1.2: CircleCenter(1) = 22: CircleCenter(2) = 0
    Set CircleObj = ThisDrawing.ModelSpace.AddCircle(CircleCenter, 15)
    CircleObj.Color = acGreen
    ZoomExtents
    Set ACAD = Nothing
    End Sub

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Excel 2010 vba autocad

    Hi katto01

    Please wrap your code in code tags, before the moderators (come back and) get you...

    Click here - Forum rules
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button.
    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1