View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default problem with "file not found" calling a dll from VBA

Just to be sure, remove the path from the declaration and try something like
this

sPath = "C:\<path\"
sFile = "myApp.dll"

sOldDir = CurDir
ChDir sPath

On Error Resume Next
nAttr = GetAttr(sFile)
bFileExists = (Err.Number = 0) And ((nAttr And VBA.vbDirectory) = 0)
ChDir sOldDir
On Error GoTo 0

If bFileExists Then
' Call your dll function stuff here
Else
MsgBox sPath & sFile & vbCr & "not found"
End If

Regards,
Peter T


"Brian Murphy" wrote in message
...
I've tried all the things you've suggested. That's why I'm going
nuts.

I think the problem might be some other file in the Windows directory
needs to be present, and it is on some systems but not all. I have
made other dll's that don't have this problem. I'm trying to figure
out if there is some linker option I need to turn on. So far I
haven't found anything. But the more I think about it, the more
convinced I am this is the answer.

Brian