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



Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now