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

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Hi there
I would be inclined to abandon that code completely and just use the built-in shortcut feature of excel.
 
Upvote 0
Hi there
I would be inclined to abandon that code completely and just use the built-in shortcut feature of excel.

Does the built-in feature work on various workstations with different users?

If so, I am so inclined as well.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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