By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,677 Members | 1,136 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,677 IT Pros & Developers. It's quick & easy.

Visual Basic (Studio 2005) DLL called from VBA for Excel (error 453)

P: 1
hello and happy new year...
I just started a project were I need to call dll functions from within excel.
More specifically I have created a custom dll in Visual Basic (visual studio 2005) with the following code:
Expand|Select|Wrap|Line Numbers
  1. Public Class main
  3.     Public Function sayHi() As String
  4.         Return ("Hello world\n")
  5.     End Function
  7. End Class
then I try to call this from excel using
Expand|Select|Wrap|Line Numbers
  1. Declare Function tellme Lib "c:\shipping_VB.dll" Alias "sayHi()" () As String
  3. Public Sub myClick()
  4.     MsgBox tellme()
  5. End Sub
I also tried to change the alias to main.sayHi() and both these without the parenthesis...

finally I tried to make a new VB (2005) project as bellow:
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  3.     Public Declare Function DeclareBeep Lib "kernel32" Alias "Beep" _
  4.         (ByVal dwFreq As Integer, ByVal dwDuration As Integer) As Integer
  6.     Declare Auto Function sayHi Lib "c:\shipping_VB.dll" () As String
  8.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  9.         MsgBox("hi")
  10.         DeclareBeep(10000, 1000)
  11.         MsgBox(sayHi())
  12.     End Sub
  13. End Class
sadly I get the first msgbox, I get the beep but I still get an 453 error on my own custom function!!! the application finds the dll, but not the function within it!
can anyone PLEASE tell me what I am doing wrong, because I am sure it's something really stupid that I can not see at the moment...
Jan 10 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.