+ Reply to Thread
Results 1 to 15 of 15

Using DLL in VBA

  1. #1
    Registered User
    Join Date
    09-15-2011
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Using DLL in VBA

    Hello. I have a workbook that accesses a DLL in the VBA code. The workbook works fine in Excel 2007, but it gives me a "can't find file" error in Excel 2010. The file it can't find is the DLL.

    I have both 2007 and 2010 on the same computer. And I am opening the same exact file in the same location in both versions. So it's weird that it works in one, but not the other.

    Any idea? Does Excel 2010 process a DLL differently?

    Thanks,
    Headpygmie

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Using DLL in VBA

    Hello headpygmie,

    Welcome to the Forum!

    It is impossible to say what the problem with the DLL is without knowing the name of the DLL and seeing the code you are using to access it and knowing more about your system's operating system, like is it a 32 bit or a 64 bit version of 2010?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    09-15-2011
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Using DLL in VBA

    Thank you for the suggestion. The DLL is a 32-bit DLL and I'm having the same problem in both Windows XP and Windows 7 (64-bit). Excel 2010 is the 32-bit version also.

    The DLL is a third party DLL and here is the declaration for it:

    Declare Function pp_libtest Lib "KeyLBE32.dll" (ByVal testnum As Long) As Long

    The file is in my System32 folder. I've also tried putting it in a different folder and changed the declaration to point there. Same problem.

    The really weird thing is that on the computer that has both Excel 2007 and 2010, it only works on 2007. That's even when I open up the same file in the same location. And the DLL is located in the same location.

    Headpygmie

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Using DLL in VBA

    Hello headpygmie,

    The 32 in the name indicates it is for a 32 bit OS. Do you know for certain that the DLL has been registered on the system?

  5. #5
    Registered User
    Join Date
    09-15-2011
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Using DLL in VBA

    Yep, that's what I was thinking. But it is definitely registered properly. The Windows 7 system is where I have both 2007 and 2010. And it works fine when I open it up in 2007.

    And I also get the same error when I open up the file in Excel 2010 in my Windows XP system.

    HP

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Using DLL in VBA

    Hello headpygmie,

    Are you running Excel 2010 under Windows XP?

  7. #7
    Registered User
    Join Date
    09-15-2011
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Using DLL in VBA

    Yes, I am.

  8. #8
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Using DLL in VBA

    Try Regsvr32 and register it.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Using DLL in VBA

    Hello headpygmie,

    I can't say for sure because I am not familiar with your DLL but based on the behavior it is accessing one or more calls that are specific to Excel 2007. Do you know if the DLL is design to run on platforms other than 2007?

  10. #10
    Registered User
    Join Date
    09-15-2011
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Using DLL in VBA

    It's one of those DLL's where you don't need to register. You just need to declare it (which I have).

    I tried it anyways and got an error, which I expected.

  11. #11
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Using DLL in VBA

    Does the error happen at design time or run time?

  12. #12
    Registered User
    Join Date
    09-15-2011
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Using DLL in VBA

    It happens at run-time when I'm calling that routine.

  13. #13
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Using DLL in VBA

    Try a simple function in the DLL. It is probably a problem with that function.

  14. #14
    Registered User
    Join Date
    09-15-2011
    Location
    Anaheim, CA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Using DLL in VBA

    I've tried other functions in that DLL and I have the same problem. It just can't seem to "find" the DLL. But I've also tried another DLL from a different company and that one worked fine. So it's not all DLLs.

    My main concern is that the DLL works fine in Excel 2007 but not in Excel 2010 (and both Excels are on the same computer). What is 2010 doing differently?

  15. #15
    Registered User
    Join Date
    05-06-2007
    Posts
    29

    Re: Using DLL in VBA

    Hi Headpygmie

    Same problem is with me too. I am also trying to connect with third party DLL in Excel 2010 but it gives error that Microsoft Excel stopped working and excel gets crashed.
    While same file run smoothly in Excel 2007. Problem for me to use 2007 is that, I want to use sover in same excel sheet and excel 2010 solver is better than 2007.

    Please help us out
    Suhas

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1