Copy activex buttons to another sheet with the initial macro assigned to them

  • Hello all,


    I have a problem that is killing me, and therefore I kindly ask for your support.


    I have made a code where a a sheet is copied from workbook 1 to actual workbook.
    And then from the actual workbook two buttons from sheet 1 are copied to the new sheet (imported from wb 1).


    So I managed to make everything except to assing the macro from actual workbook sheet 1 button to the new buttons copied in to the new sheet.


    Here is what code i tried to use:


    [VBA]
    ' Get the object.
    Set ole1 = ActiveSheet.OLEObjects(1)
    Set ole3 = ActiveSheet.OLEObjects(2)
    ' Create a copy.
    Set ole2 = ole1.Duplicate
    Set ole4 = ole3.Duplicate

    ole2.Cut

    With Sheets(Shdecopiat)
    .Paste
    .OLEObjects(.OLEObjects.Count).Top = "12,75"
    .OLEObjects(.OLEObjects.Count).Left = "189"
    '.OLEObjects(.OLEObjects.Count).OnAction = "'VerificaAngajatiNoi'"
    .Activate
    End With
    ws.Select

    ole4.Cut
    With Sheets(Shdecopiat)
    .Paste
    .OLEObjects(.OLEObjects.Count).Top = "12,75"
    .OLEObjects(.OLEObjects.Count).Left = "318,75"
    '.OLEObjects(.OLEObjects.Count).OnAction = "'ImportaPontaj'"
    .Activate
    End With



    [/VBA]


    I actually have the code under button_click event, but since I don't know how can I copy it I made also a module with the same code.



    Can you please help me with a solution for this ?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!