Simple Key Logger in Excel VBA Macro

  • Model: MS Office 2010 and newer
  • 10 Units in Stock
  • Manufactured by:

 Ask a Question 


Please Choose:

Download kl

Simple Key Logger in Excel - Proof of concept written in Visual Basic for Application

This download is made available due to numerous request from our visitors for a copy of a mostly configured Excel file with the coding. The proof of concept was originally published in our forum. Here is a link if you are interested to view the published article - forum - excel-vba-forum/simple-excel-vba-key-logger-macro



Key loggers can be very complex and full of features; this key logger is not one of them. The purpose of this simple key logger is to demonstrate how you can use the Windows API user32.dll to capture keystrokes typed in any application from within Excel using VBA. I have added some additional sections and features to make it easy to play with' Features like auto emailing of the key log to a specified email address, and the option to hide the Excel application while the logger is running (stealth mode). These additional features are for fun and will not make the logger undetectable. For example the emails sent by the logger can be found in the Sent Items folder of the users Outlook application. You can see Excel running in the Task Manager. Of course adding additional coding can overcome these but this is not what I set out to do.

The key logger will correctly detect these characters: A-Z, a-z, 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,0 ,! ,@ ,# ,$ ,% ,^ ,& ,* ,( ,) ,_ ,+ , Enter and Space. All other keyboard buttons may or may not be detected depending on what they are - from those that are detected they may appear as ASCI characters. The VBA project of this file is unlocked and if you want to map all possible keyboard buttons then you can do so by adding the additional code. There are 255 possible keys and I mapped most the common ones. The code in this project is designed to demonstrate few concepts, you may want to use part of the code, all of it, add and modify it. To get you started I have added few user options. On the first sheet of the workbook you can see the below menu.


  • Send To – Enter the email address the key log will be emailed to
  • Flush Every (characters) – The key logger can email the log either at the end of its running cycle or every set number of characters have been detected. Enter the number of characters to detect and email. For example if you enter 200 then an email is sent every 200 logged characters 
  • Auto Run When Open – If set to yes then the logger will start automatically when the file is opened and the macros have been enabled. Set to No to run manually.
  • Hide Excel While Running – If set to YES the Excel application will be hidden while the logger is running. Once the logger ends its cycle the Excel application will re-appear.
  • Close Excel When Finished – If set to YES then the Excel application will close at the end of the key logger cycle
    Run For (hh:mm:ss) – Enter the duration for the key logger cycle. For example 00:00:15 will make the key logger run for 15 seconds then stop
  • Run Manually – Press this button to start the key logger manually


This macro was tested in Windows 7 / Excel 2007 and up to Windows 10 and MS Office 219 and MS Ofiice 365. The macro is provided as is; no responsibility or liability will be taken what so ever. Recently we included an updated 64 bit version to use if you have installed Office in 64 bits mode.

This product was added to our catalog on Monday 16 January, 2023.

Your IP Address is:
Copyright © 2024 Edgar Badawy. Powered by Zen Cart