ActiveX command button "focus" issue

canuck13

New Member
Joined
Oct 8, 2014
Messages
31
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!):
  • 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
Else
Application.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 If
End Sub</vb></code>
 
Last edited:

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top