Question:

How can I "virtually" click a button in VBA?

by  |  earlier

0 LIKES UnLike

I created a new front end for a timesheet program and it basically copies and pastes data to the old sheet but is much more useful, however there is a button on the old sheet that must be executed and I don't know how to do it via VBA. How might one "virtually" click a button (in this case a 'send' button) in VBA. Help on this really would be appreciated.

btw this execution would happen via a button click in another workbook.

 Tags:

   Report

1 ANSWERS


  1. Find out what code the other other workbook runs: right-click the button, select "Assign Macro", and note the name of the VBA sub it starts. Let's say (for the example) it's called "OldMacro"

    Then, in your first workbook's VBA, add:

    dim oBook as workbook, cBook as workbook

    set cBook = activeworkbook

    set oBook = workbooks.open ( "oldsheet.xls" )

    Application.Run oBook.FullName  & "!oldMacro"

    oBook.Close false ' Closes without saving

    cBook.activate

    This will give focus to the old workbook, run the macro, then close the old workbook and come back to the current workbook and macro.

    EDIT:

    What can I say... my interests cross lines with my job, so I have a lot of tools and programs I use on a daily basis.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.