SEANT Posted February 7, 2018 Posted February 7, 2018 I'm using AutoCAD 2016. Give me a moment and I'll try it on 2018 (the only other version I have). Quote
SEANT Posted February 7, 2018 Posted February 7, 2018 Works okay with 2018. Is you project setup something like this? Quote
xxfaxx Posted February 7, 2018 Posted February 7, 2018 sorry, my bad i was using visual basic from excel, but now using it from autocad i can make the command work except with one little thingy. After i select an entity on a leyer with which to focus, i get a new error "run-time error 91, object variable or with block variable not set", and when i click the "debug" option this part "Set objRange = objExcel.ActiveWorkbook.ActiveSheet.Range("A1")" gets highlighted in yellow... I suspect i am still doing something wrong. Quote
xxfaxx Posted February 7, 2018 Posted February 7, 2018 I could make it work somehow but i cannot select the objects i want.. I mean, when i activate the command, the information goes right to excel just like that. no preselection.. well, im still learning. I changed your code a tiny bit to get the info in the cell i want. thanks Quote
SEANT Posted February 8, 2018 Posted February 8, 2018 It sounds like you're making progress. Keep asking questions and, if necessary, post the modifications you've made. The forum will respond with the necessary corrections. Quote
xxfaxx Posted February 8, 2018 Posted February 8, 2018 Is there a book or something you recommend t see what every piece of code means?? Im using "afralisp" website and some other resources to learn autolisp and vba but i think im going to need more. I will post the code as soon as i get to the computer. Quote
SEANT Posted February 8, 2018 Posted February 8, 2018 The VBA (ActiveX) Object Model used to be included with the AutoCAD Install. I haven't seen any sign of it for some time. This Russian website has what appears to be a direct copy of the documents that I remember: http://entercad.ru/acadauto.en/ Quote
xxfaxx Posted February 9, 2018 Posted February 9, 2018 the piece of code i edited was this one Set objRange = objExcel.ActiveWorkbook.ActiveSheet.Range("A1") I changed that to this [code]Set objRange = objExcel.ActiveCell [/code] And that allowed me to get the information to a cell in excel that i had clicked previously, instead of getting the info on the first cell.. i know it is not much of a change. Trying to understand something from all that code (without knowing anything) is quite a challange. thanks for the link. i will check it out Quote
SEANT Posted February 9, 2018 Posted February 9, 2018 . . . . Trying to understand something from all that code (without knowing anything) is quite a challange. . . . Given that Excel components play a big part in that example, also see this link: https://msdn.microsoft.com/en-us/vba/excel-vba/articles/object-model-excel-vba-reference Quote
steven-g Posted February 9, 2018 Posted February 9, 2018 +1 I'm trying to get started using VBA in Autocad and this is good stuff, though I must say having used Excel VBA for many years, this isn't as straightforward as I had thought it would be. Quote
SEANT Posted February 9, 2018 Posted February 9, 2018 I, too, learned and did much of my early programming with Excel VBA. As I recall, The transition to AutoCAD did seem to present a conceptual/philosophical variance between the two APIs. It didn't take long, fortunately, to become familiar with the AutoCAD way of doing things. I don't perceive the discontinuity anymore, at least. 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.