alex140590 Posted April 26, 2016 Share Posted April 26, 2016 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 FLW40.rar Quote Link to comment Share on other sites More sharing options...
SLW210 Posted April 26, 2016 Share Posted April 26, 2016 Please read the Code posting guidelines and edit your Code to be in the Code Tags. Quote Link to comment Share on other sites More sharing options...
pefi Posted July 15, 2016 Share Posted July 15, 2016 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.