Unable to acess dll file from VBA Code. Run-time error '48': File not found

kabi.ganesh

New Member
Joined
Oct 2, 2012
Messages
7
Hi Guys,

I back again requesting your help.

My objective is:
I have a dll file, code written in C++ (i guess so) and compiled. I have no idea what is coded in there.
I have to access this dll from my VBA code, get the result from the dll. My input for the dll is 3 integer values which are in a excel sheet.

1. I have declared the dll like this (... three dot is just window dir)
<CODE>
Public Declare Function quadratic Lib "C:\...\Desktop\Test\quadratic.dll" (ByVal a As Integer, ByVal b As Integer, ByVal c As Integer) As Double
</CODE>

2. On a button click, I read the input values a,b,c from the sheet and call the function passing the arguments like
getvalue = quadratic(a, b, c)

but I get Microsoft Visual Basic error saying
"Run-time error '48': File not found: C:\...\Desktop\Test\quadratic.dll"

After this I tried to reference this dll using Tools->Reference->Browse and then mapping the dll file kept on my desktop, I get a Microsoft Visual Basic for Application error saying
Can'd add a reference to the specified file.

I have no clue how to solve this. I tried various ways by changing the VB code, but no joy. :(
Please help me at the earliest as it is very urgent.

Regards,
Kabilan<CODE></CODE>
 
Last edited by a moderator:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi Guys,

Can someone help me on this issue? This is really urgent for me. Thank you.

--Kabilan

Hi,

I think you may need to register the DLL file. Sample usage for registering a dll would be like below:

click start and in run enter the below:
<tt>regsvr32 "c:\program files\common files\microsoft shared\dao\dao360.dll"</tt>
 
Last edited by a moderator:
Upvote 0
Hi IluvXcel,

I tried registering the dll as you said and I get RegSvr32 warning message saying "LoadLibrary("C:/Documents") failed - The specified module could not be found."

I am not sure if this is a permission problem on my system to make changes to C drive. I will try this as admin user.

Will there be any other way to resolve this?

--Kabilan
 
Upvote 0
Hi IluvXcel,

I tried registering the dll as you said and I get RegSvr32 warning message saying "LoadLibrary("C:/Documents") failed - The specified module could not be found."

I am not sure if this is a permission problem on my system to make changes to C drive. I will try this as admin user.

Will there be any other way to resolve this?

--Kabilan
Does your DLL have any entry points to be look at by server during registration? If not - REGSRV should fail.
Do you have C/C++ header file with prototypes of function exported from the DLL?
Try to IMPDEF/DUMPBIN/... to make sure the function name is exported properly (un-mangled).
Hint: in BASIC sizeof(int)=2 and in modern C comps it is 4.
What are your XL and OS versions?
 
Upvote 0

Forum statistics

Threads
1,215,633
Messages
6,125,928
Members
449,274
Latest member
mrcsbenson

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