Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cannot Delete an ActiveX Control
Under the assumption that you're not actually in Design
Mode: 1) Select View|Toolbars|Control Toolbox to display the Control Toolbox. 2) Press the control at the upper-left corner of the Control Toolbox toolbar (if it's not already activated). This will put you in Design Mode. 3) When you hold the mouse pointer over the Listbox it should convert to a North-West Arrow. If it does then click on the Listbox to activate the Listbox and press Delete. 4) If the Listbox did not delete then, as a last resort, try the following: Note that if a Listbox does not contain any items then it won't recognize either the Click or MouseDown events. It will recognize the MouseMove event however. I am assuming that your Listbox does NOT contain any items. So we must first add an item. The below MouseMove code will add an item and the Listbox will then recognize the Click event. We will then use the Click event to delete the Listbox. If we were to place the delete statement in the MouseMove code and use the MouseMove event to delete the Listbox (i.e. skip the Click event code) then it will crash Excel (at least on my system). ***** Paste the code to the worksheet code module ***** Dim ItemAdded As Boolean Private Sub ListBox1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) Dim obj As OLEObject If ItemAdded = True Then Exit Sub 'Limit to one added item. For Each obj In ActiveSheet.OLEObjects If TypeOf obj.Object Is MSForms.ListBox Then obj.Object.AddItem "Test ABCDE" End If Next ItemAdded = True End Sub Private Sub ListBox1_Click() Dim obj As OLEObject For Each obj In ActiveSheet.OLEObjects If TypeOf obj.Object Is MSForms.ListBox Then obj.Delete Next End Sub After pasting the code to the code module involved you should be able to delete the Listbox by clicking on it. If the Listbox is not named ListBox1 then you'll have to change the code to suit. Hope it works!!! Regards, Greg -----Original Message----- I have a worksheet with an ActiveX list box. If I go to design view and right click - no shortcut menu comes up... How to delete this control? Lucky . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2007 Form Control/ActiveX Control font difference | Excel Discussion (Misc queries) | |||
ActiveX Control text box | Excel Worksheet Functions | |||
ActiveX Control Compatibility | Excel Discussion (Misc queries) | |||
Tab to an ActiveX control? | Excel Discussion (Misc queries) | |||
Datagrid ActiveX Control | Excel Programming |