QuinRiva
07-09-2008, 12:09 AM
I have this very simlpe code to create a series of buttons:
Sub AddButton(x, y, ID)
If i < 10 Then
cname = "ViewCard0" & ID
Else
cname = "ViewCard" & ID
End If
With ActiveSheet.Buttons.Add(x * 15, y * 7.5, 60, 22.5)
.OnAction = "cmdViewCards"
.Name = cname
.Caption = Colours(ID - 1)
End With
End Sub
NB: Colours() is just a public array
I execute this code as part of a loop by simply
Call AddButton(x, y, ID)
The loop loops 12 times and creates 12 buttons. With this line commented out, it takes about 3.7 seconds to execute the loop (which is understandable, because the loop imports and resizes about 75 200kb images). But when I remove the comment and add the buttons as well, the execution times scyrockets to upwards of 17 seconds.
That would seem to indicate that adding each button takes a full '1 second'. What's going on here?
Sub AddButton(x, y, ID)
If i < 10 Then
cname = "ViewCard0" & ID
Else
cname = "ViewCard" & ID
End If
With ActiveSheet.Buttons.Add(x * 15, y * 7.5, 60, 22.5)
.OnAction = "cmdViewCards"
.Name = cname
.Caption = Colours(ID - 1)
End With
End Sub
NB: Colours() is just a public array
I execute this code as part of a loop by simply
Call AddButton(x, y, ID)
The loop loops 12 times and creates 12 buttons. With this line commented out, it takes about 3.7 seconds to execute the loop (which is understandable, because the loop imports and resizes about 75 200kb images). But when I remove the comment and add the buttons as well, the execution times scyrockets to upwards of 17 seconds.
That would seem to indicate that adding each button takes a full '1 second'. What's going on here?