Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Activating ManualCalc for any workbook opened

I want to get excel to turn to manual calculation for any workbook used.
I thought I could use an add-in to create an automatic procedure with the
workbook open event, in order to make it generic:

Sub Workbook_Open()
If Application.Calculation = xlCalculationAutomatic Then
Application.Calculation = xlCalculationManual
End Sub

However, this seems to work only on individual workbooks since the add-in
doesn't perform any action when I open a random workbook.

Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Activating ManualCalc for any workbook opened

The workbook_Open event will fire only when the workbook with the code is
opened. So you could add that same kind of code to every workbook that needs it
-- or you could use something called an application event.

These application events run when something happens at the application
level--not specific to a worksheet or workbook.

You may want to try this (and all the code goes in the ThisWorkbook module):

Option Explicit
Private WithEvents XLApp As Excel.Application
Private Sub Workbook_Open()
Set XLApp = Excel.Application
End Sub
Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook)
ChangeTheCalculationMode
End Sub
Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook)
ChangeTheCalculationMode
End Sub
Sub ChangeTheCalculationMode()
Dim TempWkbk As Workbook
If ActiveWorkbook Is Nothing Then
Application.EnableEvents = False
Set TempWkbk = Workbooks.Add(1)
Application.EnableEvents = True
End If
XLApp.Calculation = xlCalculationManual
XLApp.Iteration = True
XLApp.MaxIterations = 9999
If TempWkbk Is Nothing Then
'do nothing
Else
TempWkbk.Close savechanges:=False
End If
End Sub

johnmasvou wrote:

I want to get excel to turn to manual calculation for any workbook used.
I thought I could use an add-in to create an automatic procedure with the
workbook open event, in order to make it generic:

Sub Workbook_Open()
If Application.Calculation = xlCalculationAutomatic Then
Application.Calculation = xlCalculationManual
End Sub

However, this seems to work only on individual workbooks since the add-in
doesn't perform any action when I open a random workbook.

Any ideas?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Activating ManualCalc for any workbook opened

Thank you very much Dave, it works fine!

It would have taken ages to write this code myself

Thanks again
Ioannis



"Dave Peterson" wrote:

The workbook_Open event will fire only when the workbook with the code is
opened. So you could add that same kind of code to every workbook that needs it
-- or you could use something called an application event.

These application events run when something happens at the application
level--not specific to a worksheet or workbook.

You may want to try this (and all the code goes in the ThisWorkbook module):

Option Explicit
Private WithEvents XLApp As Excel.Application
Private Sub Workbook_Open()
Set XLApp = Excel.Application
End Sub
Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook)
ChangeTheCalculationMode
End Sub
Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook)
ChangeTheCalculationMode
End Sub
Sub ChangeTheCalculationMode()
Dim TempWkbk As Workbook
If ActiveWorkbook Is Nothing Then
Application.EnableEvents = False
Set TempWkbk = Workbooks.Add(1)
Application.EnableEvents = True
End If
XLApp.Calculation = xlCalculationManual
XLApp.Iteration = True
XLApp.MaxIterations = 9999
If TempWkbk Is Nothing Then
'do nothing
Else
TempWkbk.Close savechanges:=False
End If
End Sub

johnmasvou wrote:

I want to get excel to turn to manual calculation for any workbook used.
I thought I could use an add-in to create an automatic procedure with the
workbook open event, in order to make it generic:

Sub Workbook_Open()
If Application.Calculation = xlCalculationAutomatic Then
Application.Calculation = xlCalculationManual
End Sub

However, this seems to work only on individual workbooks since the add-in
doesn't perform any action when I open a random workbook.

Any ideas?


--

Dave Peterson

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
AutoCalc Worksheet in ManualCalc Workbook Robert Excel Programming 2 October 6th 05 02:36 AM
Opening a workbook if not opened, going to it if already opened neotokyo[_3_] Excel Programming 0 September 24th 04 08:56 PM
Opening a workbook if not opened, going to it if already opened neotokyo[_2_] Excel Programming 1 September 24th 04 07:17 PM
Opening a workbook if not opened, going to it if already opened neotokyo Excel Programming 1 September 24th 04 06:33 PM
How to see if the opened workbook is opened by another user ? balexis Excel Programming 1 August 18th 04 04:11 PM


All times are GMT +1. The time now is 04:09 AM.

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

About Us

"It's about Microsoft Excel"