Accessing AutoCAD using Excel and VB.Net, is it possible?

Accessing AutoCAD using Excel and VB.Net, is it possible?

Anonymous
Not applicable
1,983 Views
3 Replies
Message 1 of 4

Accessing AutoCAD using Excel and VB.Net, is it possible?

Anonymous
Not applicable

Hey everyone,

 

I've been able to develop an AutoCAD .dll file with the ability to export a parts list, change block information on request, etc. A lot of the things I do at work require using Excel to get the information from the drawing into our database systems. However, I'm realizing that it would be really nice if we could not only do things from AutoCAD but also start a lot of these processes in Excel using the same code in the .dll file, not just from the command line in AutoCAD. The trouble is, I'm not sure if this is even possible. My current attempts have given me a "Common Language Runtime detected an invalid program" error.

 

So, to summarize, my ideal scenario is to have functions written in my AutoCAD .dll file that someone using Excel could access using a certain workbook. However, if that wouldn't work I'll understand. I've tried to look into this online, but it's usually having AutoCAD refer to Excel, not in the reverse.

 

Thanks,

Nic

0 Likes
Accepted solutions (1)
1,984 Views
3 Replies
Replies (3)
Message 2 of 4

ActivistInvestor
Mentor
Mentor
Accepted solution

You can expose classes in in your AutoCAD extension .dll as COM objects, which allows them to be accessed from any automation client, like Excel.

 

That requires you to build classes that derived from System.ServiceModel.ServicedComponent, and are 'COM-Visible'. To access those COM objects from an automation client, you first access AutoCAD as an automation server, and use the AcadApplication's GetInterfaceObject() method to get a reference to your Com-visible classes.

 


@Anonymous wrote:

Hey everyone,

 

I've been able to develop an AutoCAD .dll file with the ability to export a parts list, change block information on request, etc. A lot of the things I do at work require using Excel to get the information from the drawing into our database systems. However, I'm realizing that it would be really nice if we could not only do things from AutoCAD but also start a lot of these processes in Excel using the same code in the .dll file, not just from the command line in AutoCAD. The trouble is, I'm not sure if this is even possible. My current attempts have given me a "Common Language Runtime detected an invalid program" error.

 

So, to summarize, my ideal scenario is to have functions written in my AutoCAD .dll file that someone using Excel could access using a certain workbook. However, if that wouldn't work I'll understand. I've tried to look into this online, but it's usually having AutoCAD refer to Excel, not in the reverse.

 

Thanks,

Nic


 

0 Likes
Message 3 of 4

Keith.Brown
Advisor
Advisor

@Anonymous wrote:

Hey everyone,

 

I've been able to develop an AutoCAD .dll file with the ability to export a parts list, change block information on request, etc. A lot of the things I do at work require using Excel to get the information from the drawing into our database systems. However, I'm realizing that it would be really nice if we could not only do things from AutoCAD but also start a lot of these processes in Excel using the same code in the .dll file, not just from the command line in AutoCAD. The trouble is, I'm not sure if this is even possible. My current attempts have given me a "Common Language Runtime detected an invalid program" error.

 

So, to summarize, my ideal scenario is to have functions written in my AutoCAD .dll file that someone using Excel could access using a certain workbook. However, if that wouldn't work I'll understand. I've tried to look into this online, but it's usually having AutoCAD refer to Excel, not in the reverse.

 

Thanks,

Nic


Hi,

 

If you are willing to not use Excel directly then you have some choices.  I use https://www.gemboxsoftware.com/spreadsheet for all of my Excel needs.  It allows you to use WPF or Winforms to view and edit spreadsheets that are 100 percent compatible with Excel without the need for the user to have excel installed.  

 

Additionally they have a free mode that contains all of the features but limits the number of sheets and rows per sheet.  Depending on your spec, this might be enough for what you need.  With a just a little bit of work, you can create an excel like application directly in AutoCAD that has just the features that you need.  So instead of going Excel to AutoCAD you can just do everything in AutoCAD.   If you are using VBA in Excel to do your communication with the databases then this might not be the best for you.

 

I

0 Likes
Message 4 of 4

Anonymous
Not applicable

@ActivistInvestor thank you for the information. That helped me know what to look for and now I know how to go about it. I've been busy at work doing other things, but I will be attempting to implement this in the coming weeks. 

 

@Keith.Brown sadly for my work I need to use Excel. It's the accepted software for the company I work for and implementing something new tends to be a difficult endeavor. 

0 Likes