Jump to content
jackseel

Auto cad --> excel

Recommended Posts

SEANT

I'm using AutoCAD 2016. Give me a moment and I'll try it on 2018 (the only other version I have).

Share this post


Link to post
Share on other sites
SEANT

Works okay with 2018. Is you project setup something like this?VBAIDE.jpg

Share this post


Link to post
Share on other sites
xxfaxx

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.

Share this post


Link to post
Share on other sites
xxfaxx

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

Share this post


Link to post
Share on other sites
SEANT

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.

Share this post


Link to post
Share on other sites
xxfaxx

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.

Share this post


Link to post
Share on other sites
SEANT

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/

Share this post


Link to post
Share on other sites
xxfaxx

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

Share this post


Link to post
Share on other sites
steven-g

+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.

Share this post


Link to post
Share on other sites
SEANT

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×