I've been writing a series of increasingly complex macros for VBA that automate repetitive SAP tasks using the "SAP GUI Scripting API." I record a macro in SAP using "Script Recording and Playback" and copy paste the GUI commands into a loop in my VBA code.
I've been running into a problem where VBA will try to execute the commands too fast and it will attempt to execute command (n + 1) before SAP is finished with command (n) resulting in my program crashing.
I'm looking for a way to close the communication loop whereby SAP can send a message to VBA that it is done with command (n) and ready for command (n + 1). In the mean time I've been able to get my code to limp along by added a sleep call between every SAP GUI command, but this solution isn't very robust and will randomly fail.