How to call a DLL from excel?

Landcruiser87

New Member
Joined
Feb 7, 2008
Messages
16
Greetings to the masses of excel officianado's,

When it comes to using VBA to manipulate excel, i don't have too many quandaries, yet when it comes to communicating with other programs, i'm not up to speed. I was given the SDK to a third party software to interact with monitoring device that spits out numbers i'd like to see directly imported to Excel. I was told i could use the DLL provided in the SDK to access its functions and transfer them via VBA. Yet i needed to call the function FS_Initialize before i can access any of the functions. So i've been trying for the past week to access it but i just can't get it right. It looks like the DLL was written in C#/C++/Visual Studio

I've tried registering it with regsvr32, but get the error

"The module "ForesightAccessDLL.dll" was loaded, but the entry-point Dllregisterserver was not found"


I've also tried declaring it within VBA

Code:
Public Declare Function FS_Initialize Lib "C:\Program Files (x86)\Microsoft Office\Office12\ForesightAccessDLL.dll" (ByRef Arg1 as Integer, ByRef Arg2 as integer) as Boolean

But then when i try to call the function, i get this error

"Can't find entry point FS_Initialize in "C:\Program Files (x86)\Microsoft Office\Office12\ForesightAccessDLL.dll"

This is where i find myself currently stuck. Any help would be greatly appreciated.

Thanks as always,

Andy
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I attempted calling it with the following code

Code:
Sub Test

Dim arg1 as integer
Dim arg2 as integer

arg1 = 1
arg2 = 1

If FS_INITIALIZE(Arg1, Arg2) = False Then
[INDENT]Dim Num as integer
    
Num = MsgBox("It worked")
End
End If[/INDENT]
End Sub
 
Upvote 0
Since the DLL does not have an entry point, one might try to make a TLB file and reference that.
 
Upvote 0
Tlbexp.exe could not create the TLB.

This returns False:
Code:
Declare Function FS_Initialize _
  Lib "x:\DLLs\ForesightAccessDLL.dll" _
  Alias "_FS_Initialize@8" _
  (ByRef arg1 As Integer, ByRef arg2 As Integer) As Boolean

Sub ForesightAccessDLL()
  Dim arg1 As Integer, arg2 As Integer
  arg1 = 1
  arg2 = 1

  MsgBox FS_Initialize(arg1, arg2)
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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