Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Print Excel Workbook When Open

Is there a way to program an Excel file to run a macro
when the file opens?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default Print Excel Workbook When Open

Paul,

Two ways.......
One...
Create a sub in a regular module named Auto_Open
e.g.
Sub Auto_Open()
' your code here or call another sub
End Sub

or in the Workbook_Open Event
Double Click on "ThisWorkbook" in the "Projects" Window
Copy and paste the following

Private Sub Workbook_Open()
' your code here or call another sub
End Sub

John

Paul Scott wrote:

Is there a way to program an Excel file to run a macro
when the file opens?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Print Excel Workbook When Open

open the workbook, go to the VBE (Alt+F11), in the project explorer, click
on the project, then right click on the ThisWorkbook entry for that
workbook. Select view code. In the resulting code module, in the left
dropdown at the top, select workbook, and at the right dropdown select open.
At any point, the sub

Private Sub Workbook_Open()

End Sub

will appear in the module. When it does, call your macro from there

Private Sub Workbook_Open()

MyMacro

End Sub

That fires whenever a workbook is opened as long as events are enables.

Read about events at Chip Peasons site

http://www.cpearson.com/excel/event.htm



--
Regards,
Tom Ogilvy
"Paul Scott" wrote in message
...
Is there a way to program an Excel file to run a macro
when the file opens?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Print Excel Workbook When Open

Got it to work. Thanks for the help.


-----Original Message-----
Paul,

Two ways.......
One...
Create a sub in a regular module named Auto_Open
e.g.
Sub Auto_Open()
' your code here or call another sub
End Sub

or in the Workbook_Open Event
Double Click on "ThisWorkbook" in the "Projects" Window
Copy and paste the following

Private Sub Workbook_Open()
' your code here or call another sub
End Sub

John

Paul Scott wrote:

Is there a way to program an Excel file to run a macro
when the file opens?


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Print Excel Workbook When Open

I got it to work. Thanks for the help.


-----Original Message-----
open the workbook, go to the VBE (Alt+F11), in the

project explorer, click
on the project, then right click on the ThisWorkbook

entry for that
workbook. Select view code. In the resulting code

module, in the left
dropdown at the top, select workbook, and at the right

dropdown select open.
At any point, the sub

Private Sub Workbook_Open()

End Sub

will appear in the module. When it does, call your

macro from there

Private Sub Workbook_Open()

MyMacro

End Sub

That fires whenever a workbook is opened as long as

events are enables.

Read about events at Chip Peasons site

http://www.cpearson.com/excel/event.htm



--
Regards,
Tom Ogilvy
"Paul Scott" wrote

in message
...
Is there a way to program an Excel file to run a macro
when the file opens?



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
Opening Excel, Book1 opens, remains open with other workbook open DanieB Excel Discussion (Misc queries) 0 September 3rd 09 08:23 AM
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
Macro to open print window and set to print entire workbook retseort Excel Discussion (Misc queries) 1 October 27th 05 11:00 PM
Excel workbook does not open in open window on desktop DeanH Excel Discussion (Misc queries) 2 March 8th 05 09:51 AM


All times are GMT +1. The time now is 05:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"