VBA - Complicated Code for Keyboard Shortcut to Launch Macro

AlexB123

Board Regular
Joined
Dec 19, 2014
Messages
207
Hello all,

I am in the process of rewriting several macros authored by several previous authors. The first of three is launched from a button on an Access form. After the first has run, users are asked to paste data into the .xlsx workbook created by the first macro before running the second. To launch the second macro, users are asked to press "Ctrl + Shift + M". Similarly, after the user has finished cleaning up data, the third is run by pressing "Ctrl + Shift + N".

These shortcuts are designed unlike any others I've seen ... I've found a number of articles on similar functions to read the Key State and pass to a program, but I do not understand what is happening and the shortcuts are now broken.

Can anyone shed light on the following? Would it be easier to create and implement another approach?

Thanks,

Code:
Function ShiftPressed() As Boolean
'Returns True if shift key is pressed
    ShiftPressed = GetKeyState(SHIFT_KEY) < 0
End Function
Sub OCRMacroPart3()
'
' Keyboard Shortcut: Ctrl+Shift+M
'Allows the macro to be run when the key combo is pressed
    Do While ShiftPressed()
        DoEvents
    Loop
 
 Do Stuf
 
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi there
I would be inclined to abandon that code completely and just use the built-in shortcut feature of excel.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top