.NET

Reply
*pkirill
Message 1 of 19 (388 Views)

Call vb.net dll from VBA?

388 Views, 18 Replies
05-17-2006 01:17 PM
So I have this VB.net app (exe) that I have compiled to a DLL. I need to try
and call it from within AutoCAD in order keep it "in process". VBA Mgr won't
let me add it as a reference, so is there some other way to call it from
VBA? I tried this statement: Declare Sub frmDLPlot_Load Lib "HCYU_DLP"
(ByVal N As Long) where HCYU_DLP is the name of the DLL and frmDLPlot_Load
is the name of the startup function in my app... I've also copied the dll to
my system32 folder...

It's entirely possible I'm doing something wrong as I am a poor hack that
has never tried anything like this before. Any help would be greatly
appreciated!

Thanks!
*Bobby C. Jones
Message 2 of 19 (388 Views)

Re: Call vb.net dll from VBA?

05-17-2006 01:22 PM in reply to: *pkirill
You need to set up your .NET assembly as a COM server.
--
Bobby C. Jones

"pkirill" wrote in message
news:5178116@discussion.autodesk.com...
So I have this VB.net app (exe) that I have compiled to a DLL. I need to try
and call it from within AutoCAD in order keep it "in process". VBA Mgr won't
let me add it as a reference, so is there some other way to call it from
VBA? I tried this statement: Declare Sub frmDLPlot_Load Lib "HCYU_DLP"
(ByVal N As Long) where HCYU_DLP is the name of the DLL and frmDLPlot_Load
is the name of the startup function in my app... I've also copied the dll to
my system32 folder...

It's entirely possible I'm doing something wrong as I am a poor hack that
has never tried anything like this before. Any help would be greatly
appreciated!

Thanks!
*pkirill
Message 3 of 19 (388 Views)

Re: Call vb.net dll from VBA?

05-17-2006 01:47 PM in reply to: *pkirill
Does that mean I have to start over?


"Bobby C. Jones" wrote in message
news:5178089@discussion.autodesk.com...
You need to set up your .NET assembly as a COM server.
--
Bobby C. Jones

"pkirill" wrote in message
news:5178116@discussion.autodesk.com...
So I have this VB.net app (exe) that I have compiled to a DLL. I need to try
and call it from within AutoCAD in order keep it "in process". VBA Mgr won't
let me add it as a reference, so is there some other way to call it from
VBA? I tried this statement: Declare Sub frmDLPlot_Load Lib "HCYU_DLP"
(ByVal N As Long) where HCYU_DLP is the name of the DLL and frmDLPlot_Load
is the name of the startup function in my app... I've also copied the dll to
my system32 folder...

It's entirely possible I'm doing something wrong as I am a poor hack that
has never tried anything like this before. Any help would be greatly
appreciated!

Thanks!
*Terry W. Dotson
Message 4 of 19 (388 Views)

Re: Call vb.net dll from VBA?

05-17-2006 02:02 PM in reply to: *pkirill
pkirill wrote:

> Does that mean I have to start over?

I have a limited knowledge of this was able to pull it off.

In the Compile section of your projects properties turn on 'Register for
COM interop'.

Terry
*Bobby C. Jones
Message 5 of 19 (388 Views)

Re: Call vb.net dll from VBA?

05-17-2006 02:29 PM in reply to: *pkirill
Probably not. Do a search for "Interop" in this group. There are some
posts that go into detail.

Have fun :-)
--
Bobby C. Jones


"pkirill" wrote in message
news:5178161@discussion.autodesk.com...
Does that mean I have to start over?


"Bobby C. Jones" wrote in message
news:5178089@discussion.autodesk.com...
You need to set up your .NET assembly as a COM server.
--
Bobby C. Jones

"pkirill" wrote in message
news:5178116@discussion.autodesk.com...
So I have this VB.net app (exe) that I have compiled to a DLL. I need to try
and call it from within AutoCAD in order keep it "in process". VBA Mgr won't
let me add it as a reference, so is there some other way to call it from
VBA? I tried this statement: Declare Sub frmDLPlot_Load Lib "HCYU_DLP"
(ByVal N As Long) where HCYU_DLP is the name of the DLL and frmDLPlot_Load
is the name of the startup function in my app... I've also copied the dll to
my system32 folder...

It's entirely possible I'm doing something wrong as I am a poor hack that
has never tried anything like this before. Any help would be greatly
appreciated!

Thanks!
*pkirill
Message 6 of 19 (388 Views)

Re: Call vb.net dll from VBA?

05-18-2006 05:41 AM in reply to: *pkirill
Thanks, Terry. Not that I had anything to do with it, but it was already
turned on... Hmm...


"Terry W. Dotson" wrote in message
news:5178177@discussion.autodesk.com...
pkirill wrote:

> Does that mean I have to start over?

I have a limited knowledge of this was able to pull it off.

In the Compile section of your projects properties turn on 'Register for
COM interop'.

Terry
*pkirill
Message 7 of 19 (388 Views)

Re: Call vb.net dll from VBA?

05-18-2006 06:31 AM in reply to: *pkirill
Well I searched and didn't find anything the helpful to me. Probably because
I didn't understand something I was reading...

I was able to add HCYU_DLP.tlb as a reference and now at least I can
display my forms from within AutoCAD. However the class and modules in my
app aren't running... The class that I have reads an INI file and
reorganizes the data and puts it into a list box for selection.

Any tips?


"Bobby C. Jones" wrote in message
news:5178211@discussion.autodesk.com...
Probably not. Do a search for "Interop" in this group. There are some
posts that go into detail.

Have fun :-)
--
Bobby C. Jones


"pkirill" wrote in message
news:5178161@discussion.autodesk.com...
Does that mean I have to start over?


"Bobby C. Jones" wrote in message
news:5178089@discussion.autodesk.com...
You need to set up your .NET assembly as a COM server.
--
Bobby C. Jones

"pkirill" wrote in message
news:5178116@discussion.autodesk.com...
So I have this VB.net app (exe) that I have compiled to a DLL. I need to try
and call it from within AutoCAD in order keep it "in process". VBA Mgr won't
let me add it as a reference, so is there some other way to call it from
VBA? I tried this statement: Declare Sub frmDLPlot_Load Lib "HCYU_DLP"
(ByVal N As Long) where HCYU_DLP is the name of the DLL and frmDLPlot_Load
is the name of the startup function in my app... I've also copied the dll to
my system32 folder...

It's entirely possible I'm doing something wrong as I am a poor hack that
has never tried anything like this before. Any help would be greatly
appreciated!

Thanks!
*James Maeding
Message 8 of 19 (388 Views)

Re: Call vb.net dll from VBA?

05-18-2006 02:26 PM in reply to: *pkirill
not that this solves the problem, but MS offers a free book on the subject of using .net dlls with VB6/VBA.
Its actually very well written and is worth reading, even though its free.
http://msdn.microsoft.com/vbrun/staythepath/additionalresources/upgradingvb6/

pkirill
|>So I have this VB.net app (exe) that I have compiled to a DLL. I need to try
|>and call it from within AutoCAD in order keep it "in process". VBA Mgr won't
|>let me add it as a reference, so is there some other way to call it from
|>VBA? I tried this statement: Declare Sub frmDLPlot_Load Lib "HCYU_DLP"
|>(ByVal N As Long) where HCYU_DLP is the name of the DLL and frmDLPlot_Load
|>is the name of the startup function in my app... I've also copied the dll to
|>my system32 folder...
|>
|>It's entirely possible I'm doing something wrong as I am a poor hack that
|>has never tried anything like this before. Any help would be greatly
|>appreciated!
|>
|>Thanks!
James Maeding
Civil Engineer and Programmer
jmaeding - athunsaker - com
Distinguished Contributor
saluki
Posts: 188
Registered: ‎09-18-2005
Message 9 of 19 (388 Views)

Re: Call vb.net dll from VBA?

05-18-2006 02:51 PM in reply to: *pkirill
Have you thought about converting your vba app to vb .net?

I migrated a few vba apps to .net relatively painlessly.

Another option would be to netload your vb.net dll then just issue the command to run the .net app to the command line through vba.
(If you don't want to netload it you could autoload it by modifying the registry).

good luck
Contributor
Chumplybum
Posts: 25
Registered: ‎12-15-2003
Message 10 of 19 (388 Views)

Re: Call vb.net dll from VBA?

05-18-2006 06:55 PM in reply to: *pkirill
apart from checking 'register for COM interop' you probably need to make sure that you're using a COM Class, as opposed to just a class... if you add a new COM Class to your project vs.net will automatically create GUID's which provide a COM identity.
this should then allow you to add it as a reference in VBA. From my experience, this works fine on the machine that you're compiling the DLL from, however, if you are using the dll on other computers you'll need to Strong Name your app and also load it into the GAC... the easiest way i've found to do this is to add a new setup/deployment project to your current project. the setup/deployment msi then does all the strong naming and loading / registrying your app (DLL file)
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.