Visual Studio Development Bookmark and Share   
 index > Visual Basic Express Edition > Excel cannot find my VB Express DLL
 

Excel cannot find my VB Express DLL

Hi all,

I am using VB Express 2008 and Excel 2007. I want to create a DLL in VB Express and call functions and procedures from the DLL in Excel VBA.

I have found many references on the web for how to do this, but I do not seem to have all the buttons in VB Express that is discussed on the forums. I end up getting an error message in VBA with the message: "Automation error - The system cannot find the file specified"

Here is what I did:

  1. Created a new project - getitright - in VB Express with the Class Library template
  2. I added a class called Class_getitright (I do not have the option to select the COM class template when I create a class)
  3. This is the code in the class (I did not go the GUID route as I do not have the option under Tools to create new GUIDS):

Public

 

Class Class_getitright

 

Public Sub New()

 

MyBase.New()

 

End Sub

<Runtime.InteropServices.ComVisible(

True)> _

 

Public Function Add_getitright(ByVal first As Integer, ByVal second As Integer) As Integer

Add_getitright = first + second

 

End Function

End

 

Class

4. I then went to project Properties > Application > Assembly Information and I ticked the box that says "Make assembly COM visible".
5. I do NOT have the option on the Compile tab that says “Register for COM interop”
6. I then selected Build getitright from the menu
7. Next in the command window I used the regasm utility to build the tlb file, which worked
8. In Excel I went to Tools > References and added the getitright.tlb file
9. In VBA, I put the following code:

Option Explicit

Sub test_dll()

    Dim MF As New getitright.Class_getitright
    Dim x As Integer
    Dim y As Integer
    Dim answer As Integer

    x = 1
    y = 2

    answer = MF.Add_getitright(x, y)
    Debug.Print (answer)
   
End Sub

But when I run it I get the error "Automation error - The system cannot find the file specified"

What am I doing wrong or how can I make the setting "Register for COM interop" visible in my Compile tab in VB Express 2008?

Not sure if this is a VB issue or a VBA issue, so please redirect me if Im in the wrong forum.

Thanks in advance!

Is268  Tuesday, October 13, 2009 8:52 AM
You need to use the Regasm utility if you cannot register the component for COM interop from the IDE. See the following article:

How to call a Visual Basic .NET or Visual Basic 2005 assembly from Visual Basic 6.0


Paul ~~~~ Microsoft MVP (Visual Basic)
  • Marked As Answer byIs268 Wednesday, October 14, 2009 10:31 AM
  •  
Paul P Clement IV  Tuesday, October 13, 2009 1:21 PM
You need to use the Regasm utility if you cannot register the component for COM interop from the IDE. See the following article:

How to call a Visual Basic .NET or Visual Basic 2005 assembly from Visual Basic 6.0


Paul ~~~~ Microsoft MVP (Visual Basic)
  • Marked As Answer byIs268 Wednesday, October 14, 2009 10:31 AM
  •  
Paul P Clement IV  Tuesday, October 13, 2009 1:21 PM

Thanks Paul, I have used the regasm utility (see step 7 above) but I did not strong sign the assembly.

It works now - thanks a lot!

Is268  Wednesday, October 14, 2009 10:33 AM
That should be fine. You don't need to strong name the DLL unless you're installing it into the Global Assembly Cache (GAC).

Paul ~~~~ Microsoft MVP (Visual Basic)
Paul P Clement IV  Wednesday, October 14, 2009 12:21 PM

You can use google to search for other answers

Custom Search

More Threads

• Debugging running very slow
• How can i delete a listbox at run time which was created also during run time
• Activation in a school envirement with mandatory profiles
• Best book to learn VB.NET 2008
• Update Column from textbox field
• GZipStream and decompression
• Visual Basic 2005 Exe
• Copy selected text from word using DsoFramer
• Close button
• Navigating thru Datagridview!!!