ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Start macro by Command Button? (https://www.excelbanter.com/excel-programming/322711-start-macro-command-button.html)

KentÄ

Start macro by Command Button?
 
Hi
I would like to start a macro which open another excelfile, by clicking a
commandbutton.
Thanks for your help
KentÄ


Tom Ogilvy

Start macro by Command Button?
 
drag a commandbutton to the worksheet.

double click on it

Private Sub Commandbutton1_click()
Workbooks.Open "C:\Myfolder\MyFile.xls"
End Sub

return to Excel

take the sheet out of design mode by clicking on the icon in the upper left
corner of the Control Toolbox Toolbar (which should appear depressed since
the sheet is in design mode)

--
Regards,
Tom Ogilvy


"KentÄ" wrote in message
...
Hi
I would like to start a macro which open another excelfile, by clicking a
commandbutton.
Thanks for your help
KentÄ




KentÄ[_2_]

Start macro by Command Button?
 
Thank's Tom
Sorry, but I want to run a macro (in Module StartUp) by clicking at the
Command Button.
The macro will open the file and execute futher commands.
Thank's for help in advance
Regards
KentÄ

"Tom Ogilvy" wrote:

drag a commandbutton to the worksheet.

double click on it

Private Sub Commandbutton1_click()
Workbooks.Open "C:\Myfolder\MyFile.xls"
End Sub

return to Excel

take the sheet out of design mode by clicking on the icon in the upper left
corner of the Control Toolbox Toolbar (which should appear depressed since
the sheet is in design mode)

--
Regards,
Tom Ogilvy


"KentÄ" wrote in message
...
Hi
I would like to start a macro which open another excelfile, by clicking a
commandbutton.
Thanks for your help
KentÄ





Tom Ogilvy

Start macro by Command Button?
 
Private Sub Commandbutton1_click()
Startup.OpenBook
End Sub

in a module named Startup

Sub OpenBook()
Workbooks.Open "C:\Myfolder\MyFile.xls"
End sub


in the workbook that will be opend (MyFile.xls), use the Workbook_Open event

See Chip Pearson's page on events
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy


"KentÄ" wrote in message
...
Thank's Tom
Sorry, but I want to run a macro (in Module StartUp) by clicking at the
Command Button.
The macro will open the file and execute futher commands.
Thank's for help in advance
Regards
KentÄ

"Tom Ogilvy" wrote:

drag a commandbutton to the worksheet.

double click on it

Private Sub Commandbutton1_click()
Workbooks.Open "C:\Myfolder\MyFile.xls"
End Sub

return to Excel

take the sheet out of design mode by clicking on the icon in the upper

left
corner of the Control Toolbox Toolbar (which should appear depressed

since
the sheet is in design mode)

--
Regards,
Tom Ogilvy


"KentÄ" wrote in message
...
Hi
I would like to start a macro which open another excelfile, by

clicking a
commandbutton.
Thanks for your help
KentÄ







KentÄ[_3_]

Start macro by Command Button?
 
Thank's Tom!
It works perfect
Regards KentÄ

"Tom Ogilvy" skrev:

Private Sub Commandbutton1_click()
Startup.OpenBook
End Sub

in a module named Startup

Sub OpenBook()
Workbooks.Open "C:\Myfolder\MyFile.xls"
End sub


in the workbook that will be opend (MyFile.xls), use the Workbook_Open event

See Chip Pearson's page on events
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy


"KentÄ" wrote in message
...
Thank's Tom
Sorry, but I want to run a macro (in Module StartUp) by clicking at the
Command Button.
The macro will open the file and execute futher commands.
Thank's for help in advance
Regards
KentÄ

"Tom Ogilvy" wrote:

drag a commandbutton to the worksheet.

double click on it

Private Sub Commandbutton1_click()
Workbooks.Open "C:\Myfolder\MyFile.xls"
End Sub

return to Excel

take the sheet out of design mode by clicking on the icon in the upper

left
corner of the Control Toolbox Toolbar (which should appear depressed

since
the sheet is in design mode)

--
Regards,
Tom Ogilvy


"KentÄ" wrote in message
...
Hi
I would like to start a macro which open another excelfile, by

clicking a
commandbutton.
Thanks for your help
KentÄ









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

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