vbaexcelbringtofront

How to bring to front on activex frame


I insert some frames (microsoft forms 2.0 frame) into the excel sheet. And I wish i could click one then bring it to front of all other frames. but it is not working. with the belowing code. frame1 still under the frame2,3,4... msobringtofront works well on normal inserted shapes, but not with the frame

Private Sub Frame1_Click()
ActiveSheet.Shapes("frame1").ZOrder msoBringtofront
End Sub

Solution

  • Try this

    Sub Sample()
        Dim oleObj As OLEObject
    
        Set oleObj = ActiveSheet.OLEObjects("frame1")
    
        oleObj.BringToFront
    End Sub
    

    enter image description here