SSSSS Posted February 24, 2021 Posted February 24, 2021 Hi everyone, I wrote the following code, and was expected the selected cell would be copied to AutoCAD with one click. I was able to call the Paste Special command and the Paste Special Window pop up. However, the second "Enter" does not go thru so I have to manually click on the "OK" button in order to move forward, which supposed to be done by the code. I checked and the code just stopped after the first "Enter". Below is the code and I have attached the picture of Paste Special Windows (image006) for your reference. Another question, even though I enabled the macro, the alert message still popup every time I run the macro. Why does it happen? (Please see the picture image007) Thanks everyone. Sub Button3_Click() Range("E2:G3").Select Selection.Copy Dim acadApp As Object Set acadApp = GetObject(, "AutoCAD.Application") On Error GoTo 0 If acadApp Is Nothing Then Application.CutCopyMode = True MsgBox "AutoCAD is not running", vbOKOnly, "Error" Cells(3, 5).Select Else: AppActivate "AutoCAD" acadApp.WindowState = 3 acadApp.Visible = True SendKeys ("pastespec") SendKeys "{ENTER}" SendKeys "{ENTER}" '<-- This Enter does not work End If End Sub Quote
BIGAL Posted February 25, 2021 Posted February 25, 2021 (edited) If you want text then why not just do that you can make text from excel telling Autocad what to create. Some examples I dont have a text example these are cut from some sample code can post. Set lineobj = acadDoc.ModelSpace.addline(startpoint, endpoint) Set circobj = acadDoc.ModelSpace.addcircle(cenpoint, rad) Set Pline = acadDoc.ModelSpace.AddLightWeightPolyline(cords) Set Text = acadDoc.ModelSpace.Addtext.................... A good link Edited February 25, 2021 by BIGAL Quote
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.