Jump to content

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


Recommended Posts

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


Set ACAD = CreateObject("autocad.Application")

If (Err 0) Then

MsgBox "Could Not Load AutoCAD!", vbExclamation


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


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 If


'Close AutoCAD Process



Set ACAD = Nothing

Set NewFile = Nothing


End Sub


Best regards



Link to comment
Share on other sites

  • 2 months later...

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...