How can I make the following lines run as atomic operation:
Sheets("worksheet34").Select
Range("D15").Select
Application.WindowState = xlMaximized
SetCursorPos 200, 600 'set mouse position at 200, 600
Call mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0) 'click left mouse
Application.SendKeys ("R")
I would like to be sure that all the lines will be executed at the same order without a delay between each other.
The code above is my hack for going to a specific cell and choosing REFRESH on this cell.
You can’t. You don’t have that much control over Excel to guarantee it will be atomic, and Excel WILL be doing stuff in response to your messages, including a message pump which will be required for the popup menu.
The best way to find out how to do something in Excel VBA is to record a macro and look at the generated code.
In your specific case, the
Calculate()method of a cell or range should refresh the value.