Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA Excel Cannot find DLL

Tags:

excel

vba

dll

I am currently trying to add control to a Power Analyzer in an excel tool. The company provides USB drivers and the appropriate modules and DLLs. I added the DLLs to the System32 folder to ensure they were read in the path. After importing the modules and trying to run the program, I get the error "File Not Found". I then tried to hard code the location of the DLL and I received the same error.

I've looked around the internet and the only issue I could find was possibly a dependency missing from the DLL. An example of the line I'm trying to use is:

Declare Function TmSend Lib "tmctl.dll" (ByVal id As Long, ByVal msg As String) As Long

This line is apart of the module provided by the manufacturer. Is there something I'm missing to get this to work? I want to make sure before I contact the manufacturer.

EDIT:

It appears that the manufacturer uploaded a corrupt DLL causing the issue to arise. When checking the file with Dependency Walker, it failed to even read the DLL.

like image 567
Talls Avatar asked Oct 25 '13 13:10

Talls


People also ask

How do I reference a DLL in Excel VBA?

ie Tools > reference then browse and select the dll. You may need to register it first, via Regserve32. Just run it from the Windows Start Run dialog.

How do I use .NET DLL in VBA?

-from Excel add reference to the generated tlb file : VBA Editor -> Tools -> References -> Browse -> Select the tlb file -> OK . Then run the previous code, I hope it will run successfully . Based on the comment, It works by building the DLL for x64 architecture, So, no need for other steps in EDIT #1.

What is DLL in VBA?

Running DLLs from VBA. DLLs (dynamic-link libraries) are portable libraries that can be created by one application and used by another. In particular one can create a DLL in C then have its functions run from Excel by calling them from VBA. Creating and using DLLs is not too difficult.


1 Answers

I see from your question that you've tried all the normal things (making sure the dll is on your path &c.)

You now need to examine the dll carefully. Download this: http://www.dependencywalker.com/

Then use it to open your dll. All the missing dependent dlls will be clearly displayed. Put those on your path too and you're done.

(To clear up some confusion: you will not need to register this dll or add a reference to it.)

like image 135
Bathsheba Avatar answered Nov 14 '22 23:11

Bathsheba