Hello all,
Having a problem w/ the following code involving two ActiveX command buttons "DeleteMap" and "ImportMap". In my import map sub (not shown) I have the user select an image then hide the ImportMap button and show DeleteMap. As you see I do the reverse here in the "Else" portion of my If statement. That all works fine except if I click cancel to the original message box. My code says exit sub which it does but my ImportMap button shows up and appears to have focus set on it (my DeleteMap button is also still visible). The reason I believe it is a focus issue is as soon as I click elsewhere the ImportMap button disappears, but while it is visible I can click it which is what I'm trying to prevent the user from doing. So I've tried all of these in front of Exit Sub but get the same result above (or an error for an unsupported method with .Activate and .SetFocus which I knew would happen but had to try!):
Any ideas? Thanks.
<code>
<vb>Sub DeleteMap()
Set wsRace = ActiveSheet 'Public variable
'deletes current map
If MsgBox("The map currently shown will be removed. Are you sure you want to continue?", _
End Sub</vb></code>
Having a problem w/ the following code involving two ActiveX command buttons "DeleteMap" and "ImportMap". In my import map sub (not shown) I have the user select an image then hide the ImportMap button and show DeleteMap. As you see I do the reverse here in the "Else" portion of my If statement. That all works fine except if I click cancel to the original message box. My code says exit sub which it does but my ImportMap button shows up and appears to have focus set on it (my DeleteMap button is also still visible). The reason I believe it is a focus issue is as soon as I click elsewhere the ImportMap button disappears, but while it is visible I can click it which is what I'm trying to prevent the user from doing. So I've tried all of these in front of Exit Sub but get the same result above (or an error for an unsupported method with .Activate and .SetFocus which I knew would happen but had to try!):
- ActiveSheet.Shapes("DeleteMap").Select
- ActiveSheet.Shapes("DeleteMap").Activate
- ActiveSheet.Shapes("DeleteMap").Setfocus
- Range("A1").Select
- ActiveSheet.Shapes("ImportMap").Visible = False
Any ideas? Thanks.
<code>
<vb>Sub DeleteMap()
Set wsRace = ActiveSheet 'Public variable
'deletes current map
If MsgBox("The map currently shown will be removed. Are you sure you want to continue?", _
vbOKCancel + vbQuestion, "Erase current map?") = vbCancel Then
Exit Sub 'ISSUE ABOVE OCCURING HERE
ElseApplication.ScreenUpdating = False
Call ImportModule.ImportPrep
ActiveSheet.Shapes("Map").Delete
Range("O8") = 0 'Reset checkbox to incomplete
ActiveSheet.Shapes("DeleteMap").Visible = False 'Reset buttons
ActiveSheet.Shapes("ImportMap").Visible = True
Range("X8").Select
Call ImportModule.ImportWrap
Application.ScreenUpdating = True
End IfCall ImportModule.ImportPrep
ActiveSheet.Shapes("Map").Delete
Range("O8") = 0 'Reset checkbox to incomplete
ActiveSheet.Shapes("DeleteMap").Visible = False 'Reset buttons
ActiveSheet.Shapes("ImportMap").Visible = True
Range("X8").Select
Call ImportModule.ImportWrap
Application.ScreenUpdating = True
End Sub</vb></code>
Last edited: