PC Review


Reply
Thread Tools Rate Thread

Direct DLL reference?

 
 
=?Utf-8?B?WFA=?=
Guest
Posts: n/a
 
      24th Oct 2007
Is there a way, using VBA to directly reference a DLL?

Please note, I'm NOT looking for code that selects a reference in Tools then
References, but instead allows a direct DLL call.

If so, your example code would be appreciated.

Thanks much.
 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      24th Oct 2007
See the Declare statement. E.g.,

Public Declare Function MyFunction Lib "FileName.dll" (Args As Whatever) As
Long

Sub AAA()
Dim Res As Long
Res = MyFunction(123,456)
End Sub

Note that (1) you cannot call functions in a DLL created in VB with this
syntax. VB can create only ActiveX DLLs that must be created as objects. (2)
the DLL function must have been compiled with the __stdcall directive, (3)
the function must have been included in the DEF file.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"XP" <(E-Mail Removed)> wrote in message
news:F8E656B8-E5AB-4028-ACC0-(E-Mail Removed)...
> Is there a way, using VBA to directly reference a DLL?
>
> Please note, I'm NOT looking for code that selects a reference in Tools
> then
> References, but instead allows a direct DLL call.
>
> If so, your example code would be appreciated.
>
> Thanks much.


 
Reply With Quote
 
ewm
Guest
Posts: n/a
 
      4th Apr 2009
Will this work to reference a .dll that was created using VS2008 and not
registered for COM interop?

"Chip Pearson" wrote:

> See the Declare statement. E.g.,
>
> Public Declare Function MyFunction Lib "FileName.dll" (Args As Whatever) As
> Long
>
> Sub AAA()
> Dim Res As Long
> Res = MyFunction(123,456)
> End Sub
>
> Note that (1) you cannot call functions in a DLL created in VB with this
> syntax. VB can create only ActiveX DLLs that must be created as objects. (2)
> the DLL function must have been compiled with the __stdcall directive, (3)
> the function must have been included in the DEF file.
>
>
> --
> Cordially,
> Chip Pearson
> Microsoft MVP - Excel, 10 Years
> Pearson Software Consulting
> www.cpearson.com
> (email on the web site)
>
>
> "XP" <(E-Mail Removed)> wrote in message
> news:F8E656B8-E5AB-4028-ACC0-(E-Mail Removed)...
> > Is there a way, using VBA to directly reference a DLL?
> >
> > Please note, I'm NOT looking for code that selects a reference in Tools
> > then
> > References, but instead allows a direct DLL call.
> >
> > If so, your example code would be appreciated.
> >
> > Thanks much.

>

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      4th Apr 2009
>Will this work to reference a .dll that was created using VS2008 and not
>registered for COM interop?


No. The Declare statement is used for Win32 DLLs.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Fri, 3 Apr 2009 22:22:01 -0700, ewm <(E-Mail Removed)>
wrote:

>Will this work to reference a .dll that was created using VS2008 and not
>registered for COM interop?
>
>"Chip Pearson" wrote:
>
>> See the Declare statement. E.g.,
>>
>> Public Declare Function MyFunction Lib "FileName.dll" (Args As Whatever) As
>> Long
>>
>> Sub AAA()
>> Dim Res As Long
>> Res = MyFunction(123,456)
>> End Sub
>>
>> Note that (1) you cannot call functions in a DLL created in VB with this
>> syntax. VB can create only ActiveX DLLs that must be created as objects. (2)
>> the DLL function must have been compiled with the __stdcall directive, (3)
>> the function must have been included in the DEF file.
>>
>>
>> --
>> Cordially,
>> Chip Pearson
>> Microsoft MVP - Excel, 10 Years
>> Pearson Software Consulting
>> www.cpearson.com
>> (email on the web site)
>>
>>
>> "XP" <(E-Mail Removed)> wrote in message
>> news:F8E656B8-E5AB-4028-ACC0-(E-Mail Removed)...
>> > Is there a way, using VBA to directly reference a DLL?
>> >
>> > Please note, I'm NOT looking for code that selects a reference in Tools
>> > then
>> > References, but instead allows a direct DLL call.
>> >
>> > If so, your example code would be appreciated.
>> >
>> > Thanks much.

>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
reference to cells in other files: direct vs indirect Amedee Van Gasse Microsoft Excel Discussion 2 11th Aug 2009 03:19 PM
dotnet related ebook direct download site for your reference m$ Microsoft Dot NET 0 28th Dec 2007 03:29 AM
Direct reference =?Utf-8?B?QXJjaGFuYQ==?= Microsoft Excel Worksheet Functions 1 31st Aug 2006 07:44 AM
serial or parallel direct cable connection without direct connect on one computer... lab Windows XP Networking 0 13th Nov 2005 10:46 PM
VLOOKUP vs direct cell reference with linked spreadsheets =?Utf-8?B?TURX?= Microsoft Excel Worksheet Functions 2 19th Oct 2004 02:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:03 AM.