Windows API list

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Windows API list

Post by agibsonsw »

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.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
StuartR
Administrator
Posts: 12554
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Windows API list

Post by StuartR »

agibsonsw wrote:......In particular I'm looking for functions that return the user name and cursor co-ordinates...
With Google as my friend, I located these two Microsoft knowledge briefs.
StuartR


User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Windows API list

Post by agibsonsw »

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.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Windows API list

Post by agibsonsw »

StuartR wrote:
agibsonsw wrote:......In particular I'm looking for functions that return the user name and cursor co-ordinates...
With Google as my friend, I located these two Microsoft knowledge briefs.
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.)

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.

User avatar
HansV
Administrator
Posts: 77998
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Windows API list

Post by HansV »

Here is an example that should work. Copy the following code into a standard module and run the ShowCoordinates macro:

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
You can use the pt variable for something else than a message box, of course.
Best wishes,
Hans

User avatar
Don Wells
5StarLounger
Posts: 689
Joined: 27 Jan 2010, 16:45
Location: Ottawa, Ontario, Canada

Re: Windows API list

Post by Don Wells »

The user name is an Environment variable and can be returned with the following code:

Code: Select all

MsgBox "The person logged on this machine is: " & Environ("username")
A list of all environment variables can be obtained in Excel using the following code:

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
H.T.H.
Regards
Don

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Windows API list

Post by agibsonsw »

Thanks both.

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.

User avatar
Jan Karel Pieterse
Microsoft MVP
Posts: 656
Joined: 24 Jan 2010, 17:51
Status: Microsoft MVP
Location: Weert, The Netherlands

Re: Windows API list

Post by Jan Karel Pieterse »

I expect this download might help (API viewer):

http://www.activevb.de/rubriken/apiview ... 4_v310.exe
Regards,

Jan Karel Pieterse
Excel MVP jkp-ads.com

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Windows API list

Post by agibsonsw »

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.