Danny CADamarteri Posted December 19, 2019 Share Posted December 19, 2019 I have a VBA macro that passes an argument to AutoCAD command line using the 'SendCommand' function as below; ACAD.Visible = True acadCmd = "-layout & d layout1" ACAD.ActiveDocument.SendCommand acadCmd & vbCr In this instance I can delete the layout tab 'layout1' however I would like to know if it is possible to pass a string variable as the argument. I have an excel sheet with all the layout tab names that I want to delete, I then want to loop through this sheet and send the command to AutoCad to delete this tab, as below; Sub delete_tabs() On Error Resume Next Dim acadCmd, match1name, match1 As String Dim range1, total As Range Dim I As Integer If Err.Description > vbNullString Then Err.Clear Set ACAD = CreateObject("AutoCAD.Application") End If total = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row For I = 2 To total Set ACAD = GetObject(, "AutoCAD.Application") ACAD.Visible = True match1 = Sheets(1).Range("C" & I).Value match1name = Sheets(1).Range("B" & I).Value If match1 < 1 Then acadCmd = (-layout & d, match1num) ACAD.ActiveDocument.SendCommand acadCmd & vbCr End If Next I End Sub I cannot find any documentation on this SendCommand function, is it possible to do what I want? Thanks in advance! Danny Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 20, 2019 Share Posted December 20, 2019 Have you double posted ? Quote Link to comment Share on other sites More sharing options...
Danny CADamarteri Posted December 20, 2019 Author Share Posted December 20, 2019 no? first post here... Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 24, 2019 Share Posted December 24, 2019 Have a look at VBA concatetnate try this not tested acadCmd = "-layout" & " d " & layoutname 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.