|
-
Jul 25th, 2008, 03:12 AM
#1
Thread Starter
New Member
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
-
Jul 25th, 2008, 05:21 AM
#2
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
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 25th, 2008, 06:40 AM
#3
Thread Starter
New Member
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.
-
Jul 25th, 2008, 06:43 AM
#4
Re: How to register Windows API for a VBA app in VISTA
Moved To Office Development
-
Jul 25th, 2008, 07:59 AM
#5
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.
 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.
-
Jul 27th, 2008, 11:12 PM
#6
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.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 28th, 2008, 01:23 AM
#7
Re: How to register Windows API for a VBA app in VISTA
 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.
 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.
 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|