Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2007 Form Control/ActiveX Control font difference Nikko963 Excel Discussion (Misc queries) 0 April 15th 09 04:21 PM
ActiveX Control text box Mary Thomas Excel Worksheet Functions 6 September 21st 08 12:15 PM
ActiveX Control Compatibility Racer49 Excel Discussion (Misc queries) 4 May 26th 07 05:32 AM
Tab to an ActiveX control? Karin Excel Discussion (Misc queries) 0 July 6th 05 05:08 AM
Datagrid ActiveX Control MK[_2_] Excel Programming 3 August 8th 03 09:30 AM


All times are GMT +1. The time now is 03:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"