+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Forum Newbie
    Using
    AutoCAD 2015
    Join Date
    Apr 2016
    Posts
    1

    Default Insert a title Block from excel into a opened dwt with excel vba

    Registered forum members do not see this ad.

    Hello there!

    Can someone help me out?
    I have make a small Excel VBA project, that opens a dwt file "FLW40_0"(see macro below) with a button. In this dwt I have managed a A3 layout with frame and a title block (see attached file). Now after opnening the dwt I what to insert the title Block that I define in excel file (see sheet "Schriftfeld"). The block schould be on layout down left.

    Sub FLW40_0()

    Dim ACAD As Object
    Dim NewFile As Object
    Dim MyAcadPath As String
    Dim bReadOnly As Boolean

    On Error Resume Next
    Set ACAD = GetObject(, "ACAD.Application")
    If (Err <> 0) Then
    Err.Clear
    Set ACAD = CreateObject("autocad.Application")
    If (Err <> 0) Then
    MsgBox "Could Not Load AutoCAD!", vbExclamation
    End
    End If
    End If

    'If you want to see AutoCAD on screen
    ACAD.Visible = False

    MyAcadPath = "U:\AutoCAD Vorlagen\FLW40_0.dwt"
    bReadOnly = True
    Set NewFile = ACAD.Documents.Open(MyAcadPath, bReadOnly)

    If (NewFile Is Nothing) Then
    ErrorMessage:
    If NewFile = "False" Then End
    MsgBox "Could not find the required spreadsheet that should be located at" & vbCr & MyAcadPath & vbCr & "Please rename or relocate the specified file as needed."
    End
    End If

    'Close AutoCAD Process
    'ACAD.Quit

    Set ACAD = Nothing
    Set NewFile = Nothing

    End Sub

    Best regards
    Alex
    Attached Files

  2. #2
    Super Moderator SLW210's Avatar
    Computer Details
    SLW210's Computer Details
    Operating System:
    Windows 7 PRO 64-bit
    Computer:
    IBM Lenovo
    Motherboard:
    ACPI x64
    CPU:
    Pentium(R) i5 4570 @ 3.2GHz
    RAM:
    8 GB RAM
    Graphics:
    Nvidia Quadro 600 1GB
    Primary Storage:
    300 GB
    Secondary Storage:
    650GB
    Monitor:
    2x ThinkVision 24"
    Discipline
    Multi-disciplinary
    SLW210's Discipline Details
    Occupation
    Design Draftsman
    Discipline
    Multi-disciplinary
    Details
    Mostly do drafting related to manufacturing. From doing site layouts with proposed updates, additions and renovations to be budgeted and submitted for bid, to updating and changing existing drawings to reflect maintenance and repair/revision work done on site.
    Using
    AutoCAD 2018
    Join Date
    May 2007
    Location
    South Florida, USA
    Posts
    11,960

    Default

    Please read the Code posting guidelines and edit your Code to be in the Code Tags.
    “A narrow mind and a fat head invariably come on the same person” Zig Zigler



  3. #3
    Senior Member pefi's Avatar
    Using
    AutoCAD 2015
    Join Date
    Jul 2006
    Location
    Cork, Ireland
    Posts
    253

    Default

    Registered forum members do not see this ad.

    Code:
    Dim ACAD As AcadApplication
    Dim ACAD_DWG As AcadDocument
    
    Set ACAD = New AcadApplication
    ACAD.Documents.Open (FILE_PATH_TO_DWG)
    Set ACAD_DWG = ACAD.ActiveDocument
    ACAD_DWG.SendCommand "-insert" & vbCr & ACAD_BLOCK_NAME & vbCr & "0" & "," & "0" & vbCr & vbCr & vbCr & vbCr
    Code not tested as it's a stripped down version of a bigger project

Similar Threads

  1. Excel VBA insert Tag block value
    By blintz in forum .NET, ObjectARX & VBA
    Replies: 5
    Last Post: 6th Jun 2015, 07:48 am
  2. Title block to excel spreadsheet
    By keiths in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 12th Apr 2015, 11:55 pm
  3. Title block to excel spreadsheet
    By keiths in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 3rd Dec 2013, 07:26 am
  4. Import excel information into title block attribute
    By McPhersa in forum AutoCAD Beginners' Area
    Replies: 1
    Last Post: 18th May 2012, 03:26 am
  5. Excel template for a title block?
    By Ste1978 in forum AutoCAD General
    Replies: 5
    Last Post: 13th Jul 2010, 01:59 pm

Tags for this Thread

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