control names, deleting in a macro

tomross
10-08-2004, 04:55 AM
Hi -

Is there a way to be clicked on a cell and delete a control (such as a checkbox) which is currently in that cell? Deleting a row doesn't delete the control, and I can't figure out a macro that can remove controls.

I used macro recorder, but that doesn't help, as it grabs the specific name of the control and deletes it. The reason I asked if I could delete a control in a cell is this:

I have a macro that draws outlines in my database, adds info, and adds a checkbox and checks it depending on a certain criteria. I would like a macro to start with a clean slate, so to speak, and I can handle deleting all of the data. I'd like a macro to delete all of the checkboxes on my worksheet though, as they could be redrawn with the same macro at a later time and then assigned different names.

Possible?

Thanks :D

Greychild
10-08-2004, 06:14 AM
You should find the control has a TopLeftCell property. This means you can go through each control on the active sheet and test if the top left cell of the range that it sits on is in the row to be deleted. If it is, delete that control (and then the row in question).

Kluz
10-08-2004, 11:13 AM
You can delete all controls made with the Control Toolbox toolbar with:Sheets("Sheet1").OLEObjects.Delete

tomross
10-08-2004, 11:21 AM
You can delete all controls made with the Control Toolbox toolbar with:Sheets("Sheet1").OLEObjects.Delete

I may not have been the best in describing everything. I used the Forms toolbar to place the controls, not the control toolbox. I don't use the control toolbox much, but from my understanding, the code between the two is quite different.

Kluz
10-08-2004, 12:07 PM
Ok, no prob. :cool: Here is the same functionality with the Forms toolbar's controls:For Each Shp In Sheets("Sheet1").Shapes
Shp.Delete
Next ShpDon't forget to change the 'Sheet1' to your sheet's name.

NateO
10-08-2004, 12:09 PM
My Macro recorder gave me the following for deleting Form shapes:

Sheet1.DrawingObjects.Delete

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum