PDA

View Full Version : Solved: Msgbox interrupts drawing on worksheet



engeeaitch
07-23-2011, 07:03 AM
Can someone help with the following please:

I am trying to draw a circle on a Worksheet, and then display a message box. However, if I run the code below, the message box appears but there is no circle displayed. On dismissing the message box, the circle appears. Strangely, if I put a breakpoint on the msgbox line, the circle is drawn, and on resuming, the message box appears as I want it to. I have tried putting a delay between drawing the circle and displaying the message box, but this does not appear to make any difference.

It seems as if the message box is interferring with the drawing of the circle somehow. Any thoughts gratefully received.

Sub Test()
Dim o As Object
Set o = ActiveWorkbook.Worksheets("Sheet1").Ovals.Add _
(Top:=5, Left:=5, Height:=10, Width:=10)
MsgBox "hi"
End Sub

p45cal
07-23-2011, 08:25 AM
try:Sub Test()
Dim o As Object
Set o = ActiveWorkbook.Worksheets("Sheet1").Ovals.Add _
(Top:=5, Left:=5, Height:=10, Width:=10)
Application.ScreenUpdating = True
MsgBox "hi"
End Sub

engeeaitch
07-23-2011, 08:55 AM
Perfect - many thanks.