Pressing a button using a macro

G

Guest

Hi,

I'm writing a macro which opens another sheet which also contains macros
which update a DB2 database. It contains a button which is update database, i
need to know how i can have my macro simulate pressing this button
 
G

Guest

This worked:

Sub XYZ()
Dim wb As Workbook
Dim Btn As Shape
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & "MyWorkbook.xls")
ThisWorkbook.Activate
Set Btn = wb.Sheets("Data").Shapes("Button 1")
Application.Run Btn.OnAction
End Sub

Regards,
Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top