Jump to content
Sign in to follow this  
Danny CADamarteri

Using SendCommand to pass a variable

Recommended Posts

Danny CADamarteri

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

 

 

Share this post


Link to post
Share on other sites
BIGAL

Have you double posted ?

Share this post


Link to post
Share on other sites
Danny CADamarteri

no? first post here...

Share this post


Link to post
Share on other sites
BIGAL

Have a look at VBA concatetnate 

 

try this not tested

 

acadCmd = "-layout" & " d " & layoutname

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Sign in to follow this  

×
×
  • Create New...