Hello. (Office 2003)
Does anyone have a link for a list of Windows API functions -using VBA? I've been searching but the examples I've found tend to be based on other languages such as C#.
In particular I'm looking for functions that return the user name and cursor co-ordinates.
Thanks, Andy.
Windows API list
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Windows API list
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 12856
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Windows API list
With Google as my friend, I located these two Microsoft knowledge briefs.agibsonsw wrote:......In particular I'm looking for functions that return the user name and cursor co-ordinates...
StuartR
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Windows API list
That's great. I spent ages (well, a little while..) Googling. Do you have a search tip? Perhaps I should begin all my searches with 'VBA some topic' to narrow the search results?
Andy.
Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Windows API list
The mouse cursor coordinates example is an (old) visual basic example, not VBA and doesn't work as is. (This was typical when I was trawling the internet.)StuartR wrote:With Google as my friend, I located these two Microsoft knowledge briefs.agibsonsw wrote:......In particular I'm looking for functions that return the user name and cursor co-ordinates...
Any one have the VBA version? Thanks, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Administrator
- Posts: 79662
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Windows API list
Here is an example that should work. Copy the following code into a standard module and run the ShowCoordinates macro:
You can use the pt variable for something else than a message box, of course.
Code: Select all
Public Type POINTAPI
x As Long
y As Long
End Type
Public Declare Sub GetCursorPos Lib "User32" (lpPoint As POINTAPI)
Public Sub ShowCoordinates()
Dim pt As POINTAPI
GetCursorPos pt
MsgBox "X=" & pt.x & ", Y=" & pt.y, vbInformation
End Sub
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 689
- Joined: 27 Jan 2010, 16:45
- Location: Ottawa, Ontario, Canada
Re: Windows API list
The user name is an Environment variable and can be returned with the following code:A list of all environment variables can be obtained in Excel using the following code:H.T.H.
Code: Select all
MsgBox "The person logged on this machine is: " & Environ("username")
Code: Select all
Sub List_Environment_Variables()
Dim EnvString As String
Indx = 1
Do
EnvString = Environ(Indx)
Cells(Indx, 1) = EnvString
Indx = Indx + 1
Loop Until EnvString = ""
End Sub
Regards
Don
Don
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Windows API list
Thanks both.
I notice that environ is part of VBA and so is also available for MS Access. Andy.
I notice that environ is part of VBA and so is also available for MS Access. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
-
- Microsoft MVP
- Posts: 658
- Joined: 24 Jan 2010, 17:51
- Status: Microsoft MVP
- Location: Weert, The Netherlands
Re: Windows API list
I expect this download might help (API viewer):
http://www.activevb.de/rubriken/apiview ... 4_v310.exe
http://www.activevb.de/rubriken/apiview ... 4_v310.exe
-
- SilverLounger
- Posts: 2403
- Joined: 05 Feb 2010, 22:21
- Location: London ENGLAND
Re: Windows API list
Thank you. That looks a great little app. I could have hours of fun! Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.