path not found for dll.

incompetence

Registered User.
Local time
Today, 08:34
Joined
Aug 30, 2008
Messages
11
Hi,
In Acc97, I have an API call with.. lib "VBA332.dll"... . This dll is stored in the \microsoft shared\VBA folder, the call of the function works well.

If I switch to Acc2k or Acc03 with the same code, they do not seem to find the dll and generate a run time error. In references, the VBA332.dll, however, is listed and there, just the API call does not work.

I haveto copy VBA332.dll to \win32, then it works.

Questions:
why does Acc2k not look in \microsoft shared\VBA
How can I change that
can I alter the path variable from VBA to look in \microsoft shared\VBA

TIA
 
The more important question would be why do you need to use this particular dll when the 2k & later reference a more recent version of the same dll (albeit in different location).
 
You mean just not specify the dll name, only use the API name and let Acc2k figure it out?
 
No. I'm very sure that the .dll you needed is already included by default. Else, VBA wouldn't work at all.

What's the API call?
 
Private Declare Function GetCurrentVbaProject Lib "vba332.dll" Alias _
"EbGetExecutingProj" (hProject As Long) As Long

Private Declare Function GetFuncID Lib "vba332.dll" Alias "TipGetFunctionId" _
(ByVal hProject As Long, ByVal strFunctionName As String, ByRef _
strFunctionId As String) As Long

Private Declare Function GetAddr Lib "vba332.dll" Alias _
"TipGetLpfnOfFunctionId" (ByVal hProject As Long, ByVal strFunctionId As _
String, ByRef lpfn As Long) As Long
 
Hmm, and what do you need those for?
 
display the current path in a folder box (instead of file dialog box).
The template told that for 97 you need those, I belief for 2k or 03 it might be obsolete, but I do not have switch/env. code.
 
aha, yes.

This is correct; you don't need to use APIs within 2k/2003.

You can just rewrite the code to use native functions... Look in VBA editor's help about FileDialog and see if it guides you to something about Folders (as I've not had that need before).

HTH.
 
Thanks,

is there a standard conditional compiling, like if Acc97 then, else...
like in C++?

Thanks again for your help
 
yes; you preface the if/then with a #:

Code:
#Const Version=1

#If Const=1 Then

#Else

#End If

Do be sure to check VBA help about this; cant remember if #Const can accept a string, and how it would work...
 
thanks, I will look that up.
Still, to the original request, do you know which paths are used to look up a dll/file?

TIA
 
I've never had that need to use a path for a Declare statement, but I've seen an examples where you can fully qualify the path:

Code:
Private Declare Function LibFunction  Lib "C:\MyLibrary\MyDll" ...

But in my cases where I've written my custom library, I just find it easier & safer to just add it to references (on VBA editor's menu, Tools -> Reference, then Browse to the .DLL).

HTH.
 
If your application is working with a DLL file that is not contained within the Computer system, then you will need have that DLL packaged with the very same application. You must then Register that DLL to Windows. To do this you would use the regsvr32.exe utility which usually comes with the operating system or is easily downloaded anywhere.

To register your DLL with regsvr32, you can either manually enter the following string into the windows RUN dialog or shell to it within your VBA:

regsvr32 C:\MyLibraryLocation\vba332.dll

Then you will need to make sure that it is Referenced within the VBA Editor.

For applications and libraries, the first paths automatically searched within the computer system to start or initiate them are contained with the System Environment Data block and held in the Environment PATH Variable (see help with regards to the Environ Function to view Environment Variables). This is still available for the Windows XP Operating system but I believe it is just there for backward compatibility. I'm not sure if it's available for Windows VISTA versions. Most of this sort of thing is now handled through the Windows Registry. Additions to the Registry can be made here:

For User Specific Environment Variables:
HKEY_CURRENT_USER\Environment

For System-Wide Environment Variables:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SessionManager\Environment

Some paths automatically searched by the system are the Windows Folder, the System32 Folder to name just a couple. The Environment PATH Variable usually (over time) contains many many paths. This Environment PATH String can be added to so as to include (if desired) the path to your own application.

If you were to open the RUN dialog from the Windows Start Menu and you just entered Notepad, notice that Notepad fires up. You didn't need to enter the the Path and File Name of Notepad (C:\Windows\notepad.exe OR C:\Windows\System32\notepad.exe) because the operating system will look for Notepad within all the paths specified within the Environment PATH Variable String and when found, will start it. As it turns out...depending upon your specific system, notepad.exe can be found in either or both the \Windows\ folder or the \Windows\System32\ folder, both of which are specified within the Environment PATH Variable String.

To view the contents of the Environment Path Variable just run this line of code:

MsgBox "Path = " & Environ("PATH")


All the paths that are auto-searched by the Operating System are separated by a semicolon (;).

If you want to view the contents of all Variables within the System Environment then you can use these few lines of code:

Code:
Dim nCount As Integer
   nCount = 1
Do Until Environ(nCount) = ""
   MsgBox Environ(nCount)
   nCount = nCount + 1
Loop

OR

Open the RUN dialog from the Windows Start button menu, enter CMD then at the Windows DOS window prompt enter SET.

To add to the Environment PATH variable you can use the Windows API Function SetEnvironmentVariable...like this:

Declare the Function within the declarations section of a Database Code Module (not a Form Code Module):

Code:
Public Declare Function SetEnvironmentVariable Lib "kernel32" Alias "SetEnvironmentVariableA" _
                         (ByVal lpName As String, ByVal lpValue As String) As Long

then use these lines of code wherever you like:

Code:
Dim EnvirPath As String

EnvirPath = Environ("PATH") & ";E:\MyFolder"  [COLOR="DarkGreen"]'the path you want to add[/COLOR]

[COLOR="DarkGreen"]'The Environment Variable and the Supplied String arguments must
'be terminated by double Null characters (Chr$(0)).[/COLOR]
Call SetEnvironmentVariable("PATH" & Chr$(0) & Chr$(0), EnvirPath & Chr$(0) & Chr$(0))

[COLOR="DarkGreen"]'To View the new Environment PATH Variable String, un-comment the
'line below which will display a Windows DOS window and enter SET
'in the windows' command prompt.
'Shell "CMD"[/COLOR]

Do keep in mind that the path you add to the Environment PATH Variable String is only good for as long as your current application process is running. Once the Application is closed, the path you added into Environment PATH Variable String is removed.

Just food for thought..........I guess.

.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom