Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Remove buttons (97)

    I have a worksheet with various buttons to do stuff. When the user then clicks the final button to email the worksheet, I want all the buttons removed.
    Is there a generic way to do this, as I'd like to use the same generic code on several worksheets.
    Thanks for your help.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Remove buttons (97)

    How did you create the buttons? From the Forms toolbar or from the Control Toolbox?

  3. #3
    3 Star Lounger
    Join Date
    Nov 2001
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Remove buttons (97)

    From the control toolbox

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 28 Times in 28 Posts

    Re: Remove buttons (97)

    Try code like this

    Sub DeleteButtons()
    Dim ws As Worksheet
    Dim i As Long
    Set ws = Worksheets("Sheet1")
    For i = ws.OLEObjects.Count To 1 Step -1
    If ws.OLEObjects(i).progID = "Forms.CommandButton.1" Then
    ws.OLEObjects(i).Delete
    End If
    Next i
    Set ws = Nothing
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •