Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I would like to run a macro automatically when the Excel file opens. The macro is written, but what do I do from here? Thank you, Chris |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Open the Workbook.
Press "Alt + F11" Press "Ctrl + R" There will be a window labeled Project - VBAProject Inside that window there will be listed any open workbooks. Look under the workbook you're working with to find "ThisWorkbook" an double-click it. Another window will appear with "ThisWorkbook (CODE)" in the titl bar. There will be two drop down menus near the top of this window. Drop both of these down and select "Workbook" from the one on the lef and "Open" from the one on the right. The body of the window should read: Private Sub Workbook_Open() End Sub Place the code there. - Piku -- Message posted from http://www.ExcelForum.com |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Add a SUB procedure titled Auto_Open to your module.
execute your code in that SUB or call your routine as needed. The next time you open the spreadsheet your code will automatically run. Holding down the SHIFT key when opening the spreadsheet will suppress running the Auto_Open routine for testing. Sub Auto_Open() myRoutine End Sub Sub myRoutine() 'Do your code here End Sub -----Original Message----- Hello, I would like to run a macro automatically when the Excel file opens. The macro is written, but what do I do from here? Thank you, Chris . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Pikus-
Thanks! That was the simplest task ever thanks to your detailed instruction. Much appreciated. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
name your macro
auto_open see example below sub auto_open msgbox("Hello New User") end sub |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Note that this method has been deprecated in favor of using the
Workbook_Open event macro, placed in the ThisWorkbook module: Private Sub Workbook_Open() MsgBox "Hello New User" 'no parens needed End Sub One significant difference: Event macros will run if the workbook is opened from code. Automacros require an explicit RunAutoMacro statement. In article , "Drlegend" wrote: name your macro auto_open see example below sub auto_open msgbox("Hello New User") end sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro To Run Automatically For Any Worksheet Upon Opening Of THe F | Excel Discussion (Misc queries) | |||
Opening a tab automatically in a file | Excel Discussion (Misc queries) | |||
Run macro automatically on opening of worksheet | Excel Worksheet Functions | |||
Copy File Automatically on Opening It | Excel Discussion (Misc queries) | |||
How do I stop a new file from opening automatically? | Excel Discussion (Misc queries) |