Bad DLL Calling Convention (Error 49)

G

Guest

Hello,
I have the following strange problem.
I have an excel program that uses a dll. Every thing is working fine (still now) with my old laptop. But giving me error 49 - Bad DLL Calling Convention (Error 49) - in my new laptop. Files and dll are same in both the machine.

Both laptops have windows XP
Old laptop has Office XP (Office 2002) and new laptop has Office 2003

I am suspecting something wrong in Office 2003. Can anybody please tell me whats the problem?

-Thanks.
 
C

Chip Pearson

Shaikh,

Typically, you get a Bad Calling Convention error when arguments passed to
the DLL do not match the data type (long, integer, etc) or the reference
type (byval or byref) specified by the DLL.

Post your Declare statement and the code you are using to call the function.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)


Shaikh said:
Hello,
I have the following strange problem.
I have an excel program that uses a dll. Every thing is working fine
(still now) with my old laptop. But giving me error 49 - Bad DLL Calling
Convention (Error 49) - in my new laptop. Files and dll are same in both the
machine.
 
M

Michael D. Ober

I am now getting the same error on code that used to work without changing
the machine. Here's my code.

dim r as range
Set r = CreateCollectorSummary(frmCreateDesk.CreateDeskSheet(CStr(c(i))))

Elsewhere in the same module I have:

Public Function CreateCollectorSummary(collSheet As Worksheet) As Range
....
Set CreateCollectorSummary = collSheet.Range(Cells(collStartRow, 1),
Cells(collSheetRow, columns(6)))
End Function

Note that my error occurs when CreateCollectorSummary actually returns. I
have single stepped through the CreateCollectorSummary function and the last
line in it (set createcolletorsummary = ...) does work and
CreateCollectorSummary is indeed a range.

Mike.
 
R

Rob Bovey

Hi Mike,

This error message is a common symptom of a VBA project that's beginning
to become corrupted. Try downloading my code cleaner utility from the web
site below and running it on your project. If corruption is the problem,
this should clear it up.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
S

Shaikh

Dear Chip,

Here is my VBA declaration:

Declare Function steam67 Lib "steam67.dll" (ByRef temperature As
Double, ByRef pressure As Double, ByRef quality As Double, ByRef
weight As Double, ByRef enthalpy As Double, ByRef entropy As Double,
ByRef saturation_temperature As Double, ByRef saturation_pressure As
Double, ByRef degrees_superheat As Double, ByRef degrees_subcooling As
Double, ByRef viscosity As Double, ByRef critical_velocity As Double,
ByVal action As Integer) As Integer

I have put steam67.dll in C:\Windows\System32 folder

Then I am calling this dll in following function:

Public Function flash67(temperature As Double, _
pressure As Double, _
quality As Double, _
enthalpy As Double, _
entropy As Double) As Variant
Dim weight As Double
Dim saturation_temperature As Double
Dim saturation_pressure As Double
Dim degrees_superheat As Double
Dim degrees_subcooling As Double
Dim viscosity As Double
Dim critical_velocity As Double
Dim action As Integer
Dim iret As Integer

action = 2 'viscosity=1, crit_vel=2

iret = steam67(temperature, pressure, quality, weight, enthalpy,
entropy, saturation_temperature, saturation_pressure,
degrees_superheat, degrees_subcooling, viscosity, critical_velocity,
action)

flash67 = Array(temperature, pressure, quality, weight, enthalpy,
entropy, saturation_temperature, saturation_pressure,
degrees_superheat, degrees_subcooling, viscosity, critical_velocity)

End Function

I am getting error at iret = steam67(temperature, pressure ....) line
of the code. I don't know what but I think there is a problem of using
this line in office 2003. Office XP (2002) uses the same structure of
the program and does not give any error.


In steam67.h file I checked the data type and they are as following:

int steam67(double *temperature, double *pressure, double *quality,
double *weight, double *enthalpy, double *entropy, double
*saturation_temperature, double *saturation_pressure, double
*degrees_superheat, double *degrees_subcooling, double *viscosity,
double *critical_velocity, int action);

I will greatly appreciate your help. Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top