How to set a path to a dll in VBA

PC User

New Member
Joined
Dec 11, 2012
Messages
32
I'd like to ensure that my code is linking to a dll that I've placed in the same folder as my spreadsheet. What code would I use to do this? This is the code that I'm working with. The dll is swedll32.dll. https://pastebin.com/nfwkHRfA
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
I'd like to ensure that my code is linking to a dll that I've placed in the same folder as my spreadsheet. What code would I use to do this? This is the code that I'm working with. The dll is swedll32.dll. https://pastebin.com/nfwkHRfA

Take a look at the following link yo figure out how Windows searches for dlls :

https://msdn.microsoft.com/en-us/library/7d83bc18.aspx

You can also place the dll file in a folder of your choice but then you would need to fully qualify the dll path in the declare statement... So for example if you place the dll in the C:\Test directory then this is how you should call the swe_calc function :
Code:
Private Declare Function swe_calc Lib "[B][COLOR=#ff0000]C:\Test\[/COLOR]swedll32.dll[/B]" Alias "_swe_calc@24" ( _
          ByVal tjd As Double, _
          ByVal ipl As Long, _
          ByVal iflag As Long, _
          ByRef x As Double, _
          ByVal serr As String _
        ) As Long
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top