ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pressing a button using a macro (https://www.excelbanter.com/excel-programming/330995-pressing-button-using-macro.html)

Todd

Pressing a button using a macro
 
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

Greg Wilson

Pressing a button using a macro
 
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

"Todd" wrote:

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



All times are GMT +1. The time now is 10:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com