Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default Macro to run automatically on Open/Close

I've created a macro that changes the auto calc function to
manual(Tools|Options|Calculation|Manual). Here is the code it generates:

Sub AutoCalcOff()
' AutoCalcOff Macro
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
End Sub

I'd like this macro to run automatically on opening this document - not sure
how to do this.

On close, I'd also like the system to be able to revert back to the previous
setting, i.e. if the auto-calc was previously set to automatic and the macro
changed it to manual, I'd like the setting to be returned to its previous
state.

Any ideas?

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Macro to run automatically on Open/Close

The Subs you want are named
Sub Auto_Open() and
Sub Auto_Close()

They may be put in any module.
--
Best wishes,

Jim


"Sarah (OGI)" wrote:

I've created a macro that changes the auto calc function to
manual(Tools|Options|Calculation|Manual). Here is the code it generates:

Sub AutoCalcOff()
' AutoCalcOff Macro
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
End Sub

I'd like this macro to run automatically on opening this document - not sure
how to do this.

On close, I'd also like the system to be able to revert back to the previous
setting, i.e. if the auto-calc was previously set to automatic and the macro
changed it to manual, I'd like the setting to be returned to its previous
state.

Any ideas?

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro to run automatically on Open/Close

Also look at the newer workbook open and workbook beforeclose events

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

You would need to store the current settings in your open/autoopen either
using a public variable or something more persistant such as a defined name
or written to a worksheet.

--
Regards,
Tom Ogilvy


"Sarah (OGI)" wrote:

I've created a macro that changes the auto calc function to
manual(Tools|Options|Calculation|Manual). Here is the code it generates:

Sub AutoCalcOff()
' AutoCalcOff Macro
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False
End Sub

I'd like this macro to run automatically on opening this document - not sure
how to do this.

On close, I'd also like the system to be able to revert back to the previous
setting, i.e. if the auto-calc was previously set to automatic and the macro
changed it to manual, I'd like the setting to be returned to its previous
state.

Any ideas?

Thanks in advance.

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
Excel 2003 + script to open and automatically close an excel workb Neil Holden Excel Discussion (Misc queries) 1 March 4th 10 04:57 PM
VBA Project - Open/Close with Macro Danny Excel Worksheet Functions 2 September 7th 07 11:02 PM
Macro to Open, then Close another File HROBERTSON Excel Discussion (Misc queries) 1 January 8th 07 06:41 PM
run macro on close & open Stu[_27_] Excel Programming 3 October 15th 03 02:09 PM
help with macro to open and close workbooks aneurin Excel Programming 1 September 24th 03 02:14 AM


All times are GMT +1. The time now is 02:33 AM.

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"