• VBA creating button and connecting a macro (2003)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » VBA creating button and connecting a macro (2003)

    Author
    Topic
    #435331

    Hallo all,

    I need your help here.
    I have to create a button in 270 Excelbooks that will start a macro.
    The macro is already in de the workbooks.
    So what I have done is created an update macro in a new workbook. This macro will open one-by-one the 270 workbooks add the button to the correct sheet and close the workbook:

    ActiveSheet.Buttons.Add(665.25, 5.25, 244.5, 69).Select
    Selection.OnAction = “prcShowWW”
    Selection.Characters.Text = “button text”

    the problem is that after the update, I open one of the updated workbooks and press the button an error pops up, telling me that de macro could not be found.
    Looking at the button settings I see that the macro name is correct but is refrerring to the update workbook (which doesn’t have that macro)
    So this means that when creating a button in workbook (A) by code from workbook ( generates a macrolink in the button to workbook ( and that should not be the case.

    Do you have any idea how to solve this… (other than doing all the adding manualy)

    greetings,

    Patrick Schouten
    Meander Medisch Centrum
    The Netherlands

    Viewing 0 reply threads
    Author
    Replies
    • #1028570

      Like this:

      Selection.OnAction = “‘” & Activeworkbook.name & “‘!prcShowWW”

      • #1028728

        Thanks Jan Karel,

        You saved me a lot of time.

        greetings,

        Patrick Schouten
        Meander Medisch Centrum

    Viewing 0 reply threads
    Reply To: VBA creating button and connecting a macro (2003)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: