VBA is by far one of the best customization tools available to Microsoft Dynamics GP developers and as such it is widely used across a number of production environments to deliver functionality that ranges in various degrees of complexity.
However, one of the issues with VBA — at least until now — is the fact that an end user can inadvertly press CTRL+Break (older keyboards) or CTRL+C and stop the execution of a script. Now imagine if that script is say, some code developed to calculate 401K contributions when payroll is ran… the results will certainly not be pretty!
With this in mind, we can use a USER32.DLL library funcion to disable user input when critical VBA code is required to be executed in a block. The following shows how to implement such code:
We can now use this function across any of our VBA customizations, as follows:
Sample Window_BeforeOpen code
There are several applications for this code, but whatever you do, don’t forget to re-enable the user input, otherwise you will end up with one dead mouse and keyboard!
Until next post!
Mariano Gomez, MVP
Maximum Global Business, LLC