LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calling customized DLL function fails

Hello everybody,

I have a problem with calling a DLL, writen in C++, from my Excel
macro.
The function calls work with 90% of all our users but there are two
customers, where the functions are simply not executed. No error occurs
and the function returnvalue is set to 0, meaning OK.
They are both working with different machines, OS and excel versions,
so I don't think it's a version problem.

I made a special diagnosis version, showing messageboxes before and
after the function call and also from the DLL functions.
My customers get the messages from the excel macro but no messages from
the dll. Nevertheless the returnvalue is changed from 5 to 0. There is
no error message at all.

Here is, how I call the function:

Public Declare Function CalcPlanetCoordinates Lib "SemRaumTest4" (v()
As Double, ByRef x As Double, ByRef y As Double, ByVal lpName As
String) As Long

Public Sub CalculatePlanets()

Dim ret As Long
Dim x As Double
Dim y As Double
Dim vals As Range

ReDim v(0 To anzAttribs - 1) As Double

For pl = 1 To anzPlanets

'Fill vector v() with double values from spreadsheet
Set vals = Range(ActiveCell.Offset(1, pl),
ActiveCell.Offset(anzAttribs, pl))
For at = 0 To anzAttribs - 1
v(at) = CDbl(vals.Range("A" & (at + 1)).Value)
Next at

'x and y are passed by reference and after the function call
contain the results!
x = 99.99
y = 88.88
ret = 5

MsgBox "Start calling SemRaumTest4.Dll" & vbNewLine & _
"Parameter x = " & CStr(x) & vbNewLine & _
"Parameter y = " & CStr(y) & vbNewLine & _
"returnvalue = " & CStr(ret), vbOKOnly

ret = CalcPlanetCoordinates(v, x, y, "")

MsgBox "End calling SemRaumTest4.Dll" & vbNewLine & _
"Parameter x = " & CStr(x) & vbNewLine & _
"Parameter y = " & CStr(y) & vbNewLine & _
"returnvalue = " & CStr(ret), vbOKOnly

If ret = 5 Then
MsgBox "DLL function was not executed!", vbOKOnly
ret = 0
End If

'Write results to spreadsheet
If ret = 0 Then
ActiveCell.Offset(21, pl).Value = x
ActiveCell.Offset(22, pl).Value = y
Dim name As String
name = ActiveCell.Offset(0, pl).Text
CreateNewPlanetPoint x, y, name, pl
Else
ActiveCell.Offset(21, pl).Value = "DLL-Fehler " & CStr(ret)
ActiveCell.Offset(22, pl).Value = "DLL-Fehler " & CStr(ret)
End If
Next pl

Application.ScreenUpdating = True

End Sub

Has somebody an idea, what is happening here? I am totaly clueless at
the moment and would appreciate any help.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
SOS! how do I write a customized function to do multiple-value lookupin Excel 2007? LunaMoon Excel Discussion (Misc queries) 1 December 1st 09 03:40 AM
SOS! how do I write a customized function to do multiple-value lookupin Excel 2007? LunaMoon Charts and Charting in Excel 0 December 1st 09 02:37 AM
Formula Function INTO Customized Toolbar 23hitman Excel Discussion (Misc queries) 1 August 22nd 09 11:41 PM
Customized function (in cell) does not refresh value :o( MarcL Excel Discussion (Misc queries) 3 February 28th 06 08:57 PM
customized function ravi Excel Programming 2 July 21st 05 07:54 PM


All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"