Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > List Open Programs > < RunSQL v Execute | Save As Text >
List Open Programs
By Richard Rost   Richard Rost on LinkedIn Email Richard Rost   3 years ago

List All Open Programs with EnumWindows Function


 S  M  L  XL  FS  |  Slo  Reg  Fast  2x  |  Bookmark Join Now

In this Microsoft Access tutorial, I'm going to teach you how to use the EnumWindows function to list all open and running programs on your PC. This is handy if you want to switch to an application that's open, but you don't know the exact title.

Daniel from Greenville, South Carolina (a Platinum Member) asks: I'm using your AppActivate code to switch to my web browser and then copy some data from there into my Access application. Usually, the title stays the same, but once in a while, the website modifies the title just a bit, and it throws my code off. Is there any way to loop through all the open windows and look for a piece of text in the title instead of having to match the entire thing?

Members

Members will learn how to switch to the application once we've found it, copy all of the text in that application back to Access, which we can then use to do whatever we want. Whether it's parsing some data out, copying it to a table, and so on.

Silver Members and up get access to view Extended Cut videos, when available. Gold Members can download the files from class plus get access to the Code Vault. If you're not a member, Join Today!

Prerequisites

Links

Recommended Courses

Member Links

Code References

  • Declare PtrSafe Function EnumWindows Lib "user32" (ByVal lpEnumFunc As LongPtr, ByVal lParam As LongPtr) As Long
  • Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Learn More

FREE Access Beginner Level 1
FREE Access Quick Start in 30 Minutes
Access Level 2 for just $1

Free Templates

TechHelp Free Templates
Blank Template
Contact Management
Order Entry & Invoicing
More Access Templates

Resources

Diamond Sponsors - Information on our Sponsors
Mailing List - Get emails when new videos released
Consulting - Need help with your database
Tip Jar - Your tips are graciously accepted
Merch Store - Get your swag here!

Questions?

Please feel free to post your questions or comments below or post them in the Forums.

KeywordsList Open Programs in Microsoft Access

access 2016, access 2019, access 2021, access 365, microsoft access, ms access, ms access tutorial, #msaccess, #microsoftaccess, #help, #howto, #tutorial, #learn, #lesson, #training, #database, list all open windows, callback functions, enumwindows, open programs, running programs, what programs are running, switch to open window, switch to program

 

 

Comments for List Open Programs
 
Age Subject From
3 yearsListWindowsEduardo Benaim
3 yearsYou are a mind readerSandra Truax

 

Start a NEW Conversation
 
Only students may post on this page. Click here for more information on how you can set up an account. If you are a student, please Log On first. Non-students may only post in the Visitor Forum.
 
Subscribe
Subscribe to List Open Programs
Get notifications when this page is updated
 
Intro In this video, I will show you how to list all of the open programs on your PC using the EnumWindows function and VBA in Microsoft Access. We will talk about why this can be helpful, especially when you need to find and work with application windows when their titles change unexpectedly. I will walk through setting up the code to loop through all open windows, display their titles, and filter out unwanted windows for a clean list. You will also see how to search for windows by partial title, making it easier to work with your data and automate common Access tasks.
Transcript Today I am going to show you how to list all of the open programs on your PC using the Enum Windows function in Microsoft Access. Why is this useful? You will find out in just a minute.

Today's question comes from Daniel in Greenville, South Carolina, one of my platinum members. I am actually going to be visiting South Carolina this weekend myself. Daniel says, "I am using your AppActivate code to switch to my web browser and then copy some data from there into my Access application. Usually the title stays the same, but once in a while the website modifies the title just a bit and it throws my code off. Is there any way to loop through all the open windows and look for a piece of text in the title instead of having to match the entire thing?"

This happens to me all the time too, Daniel. I use some code to switch to my bank's website. I open up the bank's website and log on, and then I use some code to switch from my Access database to that window, copy the text, and bring it back so I can analyze it for balance information and such. Once in a while the bank changes the title just slightly, and one of the problems with AppActivate is that you have to know the exact title to switch to it.

I am going to show you some code that will allow you to loop through all of the open windows and then you can find a piece of that code. For example, if the window includes PayPal, you can grab that, or if it includes Regions Bank you can switch to that window. If you have five different Word documents open and you know the title of the Word document but maybe not the exact title, like the name of your document, you can switch to that.

First off, if you have not yet watched my AppActivate video, go watch this first. I show you how to shell an application. In other words, launch an application like Notepad or Calculator or whatever, and then AppActivate can be used to switch to that application.

Let's say you open up Notepad, you go back to your Access application, then you want to launch that specific Notepad again. That is what AppActivate is good for. You can switch between open applications and do things like send keys there, or you can copy information from it, and so on. Go watch this very helpful video.

Today, we are going to learn how you can list all of the open applications and switch to a specific one based on part of the title. AppActivate requires you to know the exact title that is in the Windows title bar.

This is a developer lesson, so you will need to know some VBA. If you watched the AppActivate video, you know all that stuff. So we will continue on here.

Here I am in the TechHelp free template. You know what this is already. We are going to use our little status box window here and we are going to list all of the windows that are open on the system. We are going to put them in the status box.

If you do not know what a status box is, I have a video for that too. I will put it down in the link section.

We are going to rename this button Enum Windows because that is the function we are going to use to enumerate all of the windows, to list all the windows. Right-click, build event. That is going to open up my VBA code builder. Slide this over here. Slide this up like that.

We do not want to status "hello world." Let me put some links down here because there we go. Sometimes I find it helps to put some blank lines at the bottom.

Let's put in here "enumerating windows." I think I spelled that right.

Now we are going to use a special function that is part of the Windows API: Application Programmer Interface. It is something that's built into Windows. It comes with the programming libraries that are already built into Windows, but to use it, we need to make a reference to it. You cannot put a reference to it in a form module.

So, we are just going to say "list windows," and then we are going to create our own module to put that list windows in.

Save this and we are going to come over here. You can put it in that. There is a global module in here if you want to. Let's just stick it in here. We will stick it in the global module.

Down here, we need a public sub called list windows where we do our stuff.

Now, what stuff is going to go in here? Well, first I need a way to view what I am doing. I need to update my status function.

Let's make a status function in here so that I can work with this status box, even though I am in a global module. I cannot use the other status function that is in here. I can do something similar to it though.

So, we will build a global status function. We will put it right up here and there it is. We are going to create our own status function out here that will take an "S" just like the other one does, and it does the exact same thing as the other status function except it is working with Forms!MainMenuF!StatusBox. That is the only difference. This is so the global module knows what form this box is on.

Now, when our list windows code runs, the first thing I want to do is blank that status box. Let's just set it equal to nothing, an empty string. Then we are going to do the enumeration of the windows.

Now, just like this guy right here, this Sleep function comes from Windows. See that kernel32 there? There are lots of different DLLs and other kinds of programming language stuff that come with Windows and with Office that you can use in all of your Office applications.

The two that we are going to use for this particular example are these. I'm just going to paste them in for you. There is EnumWindows and there is GetWindowText. We will need both of these to loop through all the windows that are open on the system and get the text that is in the title bar.

I am not going to explain what all of these different parameters are. I am going to show you how to use them. Think of it like driving a car. You do not need to know exactly how an internal combustion engine works in order to drive the car. So, we are going to learn how to drive the car today. I am not going to explain every little detail here.

Essentially, EnumWindows lets you loop through all the windows on the system, and GetWindowText is used to get the text of that window. I do not even remember all this stuff myself. I will either copy this from a reference book, Microsoft documentation, other websites, or a book, or whatever. There is no way I can even remember all this stuff. I don't think any developer does.

We are all copying and pasting stuff. In fact, I will put this text on my website for you to copy and paste for these functions. I do not like giving you all the text because I want you to write some of it. You learn better by typing in code yourself instead of copying and pasting everything. But the stuff that I will usually put on my website for everybody to copy is the stuff that even I copy and paste. I am not going to sit here and type this all in. I got this off the Microsoft site. So, I will put a copy of this on mine too and make it easier on you. But the rest of the code, I want you to type it. It builds your developer experience by typing stuff in.

Come back down here into list windows. Now that we have our declarations up top, we can actually use those functions. Here is what we are going to start with. We are going to start with that: EnumWindows, and then AddressOf EnumWindowsListOnly, comma zero.

Again, I am not going to explain everything in exquisite detail. But this will basically call a function that we are going to create called EnumWindowsListOnly. It is called a callback function. That means EnumWindows is going to loop through all the windows that are open, enumerate them, and every time it finds one, it is going to call our callback function and do some stuff with it.

What stuff? Well, let's tell it. Let's create our own function right here called EnumWindowsListOnly, and we need these two parameters. Type those in. If you are a Gold member, you can copy that if you want to.

EnumWindows is going to send two parameters to our function. We do not need to worry what they are. It is just going to send two things in. We have to declare a couple of variables: buffer, l, and title. Then we are going to use these variables to figure out what the title of this window is. By the time we are done with all this, we will have "title" being equal to the title of the current window in our loop and our enumeration loop.

Then we are going to use our status function to display the title of the window. We are going to say status "win: " and then title. Or you can put "window" or "program" or whatever you want to call it.

For now, we are going to enumerate all of the windows. You can put a stop in here by setting that to zero if you find the window you are looking for. We will do that in just a second. But right now, I just want to list all of them.

We should be good to go at this point. See, it is not that complicated. You do not have to know what all this stuff is to set this up. Once you get it set up, now you can play with it.

Quick Debug > Compile. Everything looks good. Let's come back out here. Let's close it, save it, open it.

My window moved. There we go. Click the button and there you go. See, it is still running. There are a lot of windows open on my system, folks. Now, there is a lot of stuff that is going to be found that is not necessarily a valid open program. Things like this "Default IME," this "MCST," whatever this stuff is. There is a lot of empty stuff in here. There is a lot of stuff. I am going to set up some empty stuff here, blank stuff.

Now there is a good program: HyperSnap. There is my Program Manager. There is my PowerPoint app that I use for my slides, and so on.

I am going to come back in here and I am going to change this and put some exclusions in here.

What exclusions? I am going to say "If the title is not empty, and not IsNull(title), and the title isn't this, and the title isn't this," and whatever other stuff irritates you. This shows up a lot for me. I use Google Drive. "System Resource Notify" window shows up a lot. So if it is not one of these things, then go ahead and list it. Just exclude the stuff you do not want to see.

Let's try it again. Much shorter list, and there is a better list of all of your actual applications out. You can hide more stuff if you want to: hide the DDE Server window, hide the Task Host window. You will eventually whittle it down to stuff that you want to see.

The bottom line is now you can find something that you are looking for and then stop.

So, let's say you are looking for, how about this: "Video Rewind" right there. That is in my WinSCP, that is what I have for my FTP program. Let's say I am looking for that. The whole title of the application is that, but let's say I am just looking for the window that says Video Rewind.

Here I could say: If InStr(title, "Video Rewind") is not zero, then status "Found it." Then we will set EnumWindowsListOnly = 0. Else, make it 1, keep looping.

Stop. Save it. And run. Stop right there. See, it went through all of them until it found Video Rewind and then said "Found it" and it stopped.

Now that you found it, you can switch to that window and do stuff. You could send keys to it, you can copy data from it, all kinds of cool stuff. But now you have located the window.

In the extended cut for the members, I am going to show you how to do the rest of that stuff that I just talked about. We are going to switch to that program, select all the text in the window, copy it, go back to Access, paste it in a text box. Then we can do stuff with it. We can parse the data, we can look for dollar amounts, we can look for certain specific information, whatever you want to do once you get the text.

We will also deal with the crazy Num Lock issue, because sometimes when you are using SendKey (we have to use SendKeys for this), when you use SendKeys the Num Lock flips on. I will just turn that back off too.

My ultimate goal, I have not done this yet, I am going to be doing this after I finish this extended cut today. I am going to be adding this to my Account Balances template, because what I do every day (and if you have watched the Account Balances videos, you know what this is designed for) is that you can keep all of your credit card accounts and your bank accounts, you keep all your account balances.

Every day, or week, or however often you do it (you should do it at least once a month), you go to the bank's website, you figure out how much your balance is, and you put that in your database.

That is a pain to have to type all that in. So what I want to do is I want to open up the website, go to my database, click a button, have it switch to that website page, copy the data, figure out what the balance is based on the text that is provided, and then automatically put that in the database.

I am going to be working on that later today, but I figured I would go through all this stuff first to show you how this works.

That is going to be covered in the extended cut: switching to the program, copying data back.

That is your TechHelp video for today. I hope you learned something. Go play with it. Go have fun. Go do some stuff with it.

Live long and prosper, my friends. I will see you next time.
Quiz Q1. What is the primary purpose of using the EnumWindows function in Microsoft Access as described in this tutorial?
A. To enumerate all controls on a form in Access
B. To loop through all open programs and windows on your PC
C. To list all tables in an Access database
D. To sort application windows automatically

Q2. Why might the AppActivate command fail to switch to the correct window?
A. Because it cannot launch new applications
B. Because it requires an exact match to the window title
C. Because it only works on minimized windows
D. Because it closes the window after activation

Q3. What advantage does the EnumWindows approach offer over AppActivate when switching to a specific program window?
A. It can start programs that are not running
B. It lets you search for a partial match in the window title
C. It only works with Microsoft Office applications
D. It ignores all hidden windows

Q4. What Windows API functions are needed to list open windows and retrieve their titles?
A. EnumWindows and GetWindowText
B. AppActivate and SetFocus
C. OpenWindow and GetHandle
D. FindWindow and WindowTitle

Q5. Where should you place the API declarations for EnumWindows and GetWindowText in your Access project?
A. In the form module
B. In a standard global module
C. In a table's property sheet
D. In the record source

Q6. What is the purpose of the callback function (EnumWindowsListOnly) in this solution?
A. To launch new applications as needed
B. To receive and process each window handle found by EnumWindows
C. To save data into the Access database automatically
D. To shut down unused windows

Q7. Which technique can be used to exclude unwanted windows from your list of open programs?
A. Only list windows with a size above a certain threshold
B. Compare the window title against a list of known unwanted titles and skip them
C. Use a special version of EnumWindows called EnumFilteredWindows
D. Exclude all windows unless they are Internet Explorer

Q8. When searching for a window with a variable title (such as a website that changes its title), how is the correct window identified?
A. By exact title match as required by AppActivate
B. By searching for a specific substring in the window title using InStr
C. By matching the window's process ID
D. By matching the window handle directly

Q9. Once the desired window is found using this approach, what is a possible next step described in the video?
A. Minimize all other windows automatically
B. Switch to that window and use SendKeys to copy data
C. Display a warning message and do nothing else
D. Terminate the found process immediately

Q10. Why does the instructor encourage typing the code yourself rather than just copying all of it?
A. Because copying causes syntax errors
B. Because typing helps you learn and build developer experience
C. Because Access does not allow pasted code
D. Because Microsoft restricts code copying for API functions

Answers: 1-B; 2-B; 3-B; 4-A; 5-B; 6-B; 7-B; 8-B; 9-B; 10-B

DISCLAIMER: Quiz questions are AI generated. If you find any that are wrong, don't make sense, or aren't related to the video topic at hand, then please post a comment and let me know. Thanks.
Summary Today's TechHelp tutorial from Access Learning Zone is all about listing all of the currently open programs on your PC using the EnumWindows function in Microsoft Access. This is a very handy skill, especially when you want to identify and interact with a window even if you do not know the exact title.

This question actually came up from a member who was using AppActivate to switch to their web browser and copy data back into Access. The issue is that AppActivate requires you to know the window's exact title, which can sometimes change if, for example, a website updates the page title slightly or adds a notification. This problem occurs often, especially if you automate tasks for applications like banking or any situation where you want to quickly grab data from another window.

To work around this limitation, I am going to demonstrate how to enumerate all open windows, allowing you to find the one you are looking for just by searching for part of the title. This is useful in cases like having several Word documents open and wanting to activate a specific one based on a partial title match, instead of needing to know the precise title in the window bar.

This lesson builds on basic VBA concepts introduced in my previous AppActivate tutorials. If you have not seen those yet, I recommend watching them so you understand how to launch and switch between applications programmatically in Access.

Today, our focus is on displaying a list of all open applications and then showing how to work with particular ones based on matching part of their window title. Access's AppActivate function is directly tied to an exact title, so expanding beyond that requires some VBA work involving Windows API calls.

For demonstration, I am working from my standard TechHelp free template. The list of windows is going to be shown in a status box control on the form. If you are not familiar with status boxes, I also have a separate video dedicated to explaining those.

To implement this, I renamed a command button to "Enum Windows" for clarity since that is what the underlying routine will be doing: enumerating all of your open windows. The event handler is set up in VBA so that when you press the button, it triggers this process.

Because we are using Windows API functions, you will need to declare certain API references in a standard module, not a form module. The two critical functions used here are EnumWindows and GetWindowText, both of which let you cycle through every open window and fetch each window's title. API declarations can seem intimidating, but you do not need to know all of their inner workings to use them effectively. If you want to learn more, you can consult Microsoft's official documentation, but for the purposes of this lesson, I will provide sample code and details on my website.

I recommend typing in much of the code yourself instead of copying and pasting, as it helps you better understand what each line does over time. That said, certain API declaration lines are best copied exactly as shown, as even small typos can break functionality.

The heart of this solution is setting up EnumWindows to loop through all windows and, for every window it finds, calling a custom callback function. This callback receives the window handle and lets you retrieve its title. Titles are then displayed one by one in the status box. Initially, this will list everything, including system processes and hidden windows, many of which are not useful for our purposes.

To clean up the list, you can filter out empty titles or specific unwanted entries by checking the window title against a list of exclusions. This produces a much more useful listing of your active applications. Once you have this working, you can further refine which windows to show by adding more exclusions as you encounter them.

The major advantage of this approach becomes clear when you want to locate a specific window without needing its full title. For example, if "Video Rewind" appears somewhere in the window title, you can set up the code to search for that text, and once found, indicate that in the status box and stop further searching. This is done by checking if the window title contains the required text using an InStr function. Once the correct window is identified, you can then proceed to activate it, send keystrokes, or extract information as needed.

This system has practical uses, such as finding your bank's website window automatically so you can copy balance information without typing it in manually. I plan to integrate this technique with my Account Balances template, which tracks balances for multiple accounts by visiting sites, copying balance text, and updating the database automatically. This approach saves time and minimizes the chance for manual errors.

In the Extended Cut for members, I will cover how to go beyond just finding the window. We will look at actually switching to the window, selecting and copying text, and pasting it back into Access, including addressing quirks such as the Num Lock key sometimes behaving unexpectedly with SendKeys. Ultimately, this will provide a fully automated workflow for fetching and processing data from other applications.

That wraps up today's tutorial. If you would like detailed, step-by-step instructions and all the supporting code, you can find a complete video tutorial on my website at the link below.

Live long and prosper, my friends.
Topic List Explaining the limitations of AppActivate with partial window titles
Using EnumWindows to list all open windows in Access
Creating a global module for window enumeration code
Declaring the EnumWindows and GetWindowText API functions
Building a status update function to display results
Writing a callback function for EnumWindows enumeration
Looping through open windows and retrieving their titles
Displaying all open window titles in a status box
Filtering window titles to exclude unwanted entries
Searching for a partial title within window names
Halting enumeration when a specific window is found
 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 3/8/2026 8:29:54 PM. PLT: 1s
Keywords: TechHelp Access list all open windows, callback functions, enumwindows, open programs, running programs, what programs are running, switch to open window, switch to program  PermaLink  List Open Programs in Microsoft Access