How to register Windows API for a VBA app in VISTA
I had a nice application which ran under Office 2003 and noteably outlook 2003 in Windows NT.
My company migrated to VISTA, still with Office 2003.
But my app dosen't run anymore and I get the message under refences that the WINdows API is not available. I also get the message that the function "SLEEP 5" does not exist (basic VBA finction!?).
So the question is how to get the Windows API in the refeence section.
- Do I have to brows to some specific location ?
- Do Ihave to download something (saw something about MDAC, is this related?)
- Does it now have another name that I can search for.
I have to clarify that I don't have the faintes how the list of stuff displayed under references is populated.
Thanks
Re: How to register Windows API for a VBA app in VISTA
sleep is not a basic VBA function or vb function
Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long) this is the api declare for sleep it also shows the dll required for the API to suceed
Re: How to register Windows API for a VBA app in VISTA
The declaration of sleep deblocks my code, thanks A LOT, but I doesn't come a long way to explaining the questions I posed.
Re: How to register Windows API for a VBA app in VISTA
Moved To Office Development
Re: How to register Windows API for a VBA app in VISTA
The Windows API cannot be added to References - you need to declare each function individually as westconn1 showed.
The reason for this is that References is for ActiveX DLL's (or EXE's), but the Windows API is built using COM DLL's.
The only way you could get it in your References is if somebody had made an ActiveX DLL/EXE that contained the declarations etc.
Quote:
Originally Posted by metramo
I have to clarify that I don't have the faintes how the list of stuff displayed under references is populated.
It shows the list of all ActiveX DLL's/EXE's that are Registered (ie: properly installed) on your computer.
Re: How to register Windows API for a VBA app in VISTA
Depending upon your app, your references may have been set under XP or other OS so when the app is used in Vista the references will break. We can not guess as to what all the other things your code does or access but perhaps you could give more details and we can tell you.
Re: How to register Windows API for a VBA app in VISTA
Quote:
Originally Posted by metramo
I get the message under refences that the WINdows API is not available. I also get the message that the function "SLEEP 5" does not exist (basic VBA function!?).
The Windows API is a series of classes and methods (usually functions), which are provided by the Operating System. They are contined within core system dll files such as Kernell32.Dll and User32.Dll. If they were "missing" you simply wouldn't have a useable Operating System, but more likely a blue screen or DOS screen and Winodws simply would not boot. There are some tutorials on the API upon this webpage if you are interested in reading more about the Windows API: http://allapi.mentalis.org/vbtutor/tutmain.shtml.
Quote:
Originally Posted by metramo
So the question is how to get the Windows API in the refeence section.
- Do I have to brows to some specific location ?
...
- Does it now have another name that I can search for.
I have to clarify that I don't have the faintes how the list of stuff displayed under references is populated.
With regard to these questions, to use any API call, you must have a declaration within your code. Westconn1 has thoughtfully provided you with the declaration for the Sleep() API call above there as an example. These declarations tell the VB runtime the signature of the method - that is, the name and return type (where used) and the method parameter arguments and their types. It also contains specific library information, as well as any alias for the method, or, in English "This is the DLL file where you can find this exposed method being called, ohh and it's other name which you'll find it under is xyz1 rather than the coded xyz call used here". A final note is that Windows and the runtime will know where this DLL file is beneath the Operating System folders so you need never to write a path preceeding the DLL file name.
Sleep is a Windows API call method and not a standard VB6 or below, or VBA one. If this worked within your application prior to your attempted execution on a Vista system, you must have had the declaration for this call contained somewhere within your code.
Quote:
Originally Posted by metramo
- Do Ihave to download something (saw something about MDAC, is this related?)
MDAC stands for Microsoft Data Access Components and includes libraries such as DAO, ADO, ODBC and possibly RDO which are all components used when communicating with databases prior to the advent of .Net.