Artik
Active Member
- Joined
- Jun 5, 2012
- Messages
- 300
I create a work schedule using graphical objects. Instead of laboriously inserting, for example, a value of 1 into multiple cells for a given worker, I drag a rectangle to the required size, and the values of 1 are inserted automatically in the cells where the object is located. In the solution, I used a stable Timer class written by Karl E. Peterson, which keeps track of when I have finished dragging the rectangle.
To schedule the working hours of a specific employee, there are two steps: 1. click with the LEFT mouse button on the specified rectangle to select it 2. change the size and/or position of the rectangle.
In the solution, I used a condition (in the Timer1_Timer procedure) that if the position and/or size of the rectangle was not changed within 10 seconds, after selecting the object, the Timer is turned off. I know that I could dispense with this condition, in which case the Timer would run indefinitely (until one of the workbook's events is detected), but I'm not sure I can predict all possible user behaviors to prevent Excel from crashing.
Problem description.
If, after selection, I grab a rectangle with the mouse and hold the mouse button down for more than 10 seconds, the Timer1_Timer event turns off the Timer. At this point, after releasing the mouse button, the rectangle "disappears" (becomes invisible) although it still exists on the sheet. Looking through the "Selection Pane" you can see that the object is not hidden, but is nevertheless invisible. When selecting an object from the list in the "Selection Pane", a "handicapped" rectangle (without filling) appears on the sheet. Strangely enough, when I click on another rectangle in the sheet, automagically this "handicapped" (but already with filling) appears on the sheet, but the values in the cells under the rectangle may not reflect its actual position and size. I tried various tricks with screen refresh, but it did not give positive results.
I am primarily interested in the root of the problem. What is the reason that the rectangle disappears? I would also appreciate if someone can find a solution to the problem (other than removing the condition from the Timer1_Timer procedure).
Schedule.xlsm
Artik
To schedule the working hours of a specific employee, there are two steps: 1. click with the LEFT mouse button on the specified rectangle to select it 2. change the size and/or position of the rectangle.
In the solution, I used a condition (in the Timer1_Timer procedure) that if the position and/or size of the rectangle was not changed within 10 seconds, after selecting the object, the Timer is turned off. I know that I could dispense with this condition, in which case the Timer would run indefinitely (until one of the workbook's events is detected), but I'm not sure I can predict all possible user behaviors to prevent Excel from crashing.
Problem description.
If, after selection, I grab a rectangle with the mouse and hold the mouse button down for more than 10 seconds, the Timer1_Timer event turns off the Timer. At this point, after releasing the mouse button, the rectangle "disappears" (becomes invisible) although it still exists on the sheet. Looking through the "Selection Pane" you can see that the object is not hidden, but is nevertheless invisible. When selecting an object from the list in the "Selection Pane", a "handicapped" rectangle (without filling) appears on the sheet. Strangely enough, when I click on another rectangle in the sheet, automagically this "handicapped" (but already with filling) appears on the sheet, but the values in the cells under the rectangle may not reflect its actual position and size. I tried various tricks with screen refresh, but it did not give positive results.
I am primarily interested in the root of the problem. What is the reason that the rectangle disappears? I would also appreciate if someone can find a solution to the problem (other than removing the condition from the Timer1_Timer procedure).
Schedule.xlsm
Artik