PC Review


Reply
Thread Tools Rate Thread

Activating ManualCalc for any workbook opened

 
 
johnmasvou
Guest
Posts: n/a
 
      18th Mar 2008
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?
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      18th Mar 2008
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 With Quote
 
johnmasvou
Guest
Posts: n/a
 
      18th Mar 2008
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exceeding 65K of defined names within workbook causes workbook to go into repair mode when it is opened Ronald Dodge Microsoft Excel Programming 13 18th May 2007 02:24 PM
How to check workbook is already opened before passing the workbook obj to a subroutine in Word Bon Microsoft Excel Programming 2 19th Jan 2006 09:54 AM
AutoCalc Worksheet in ManualCalc Workbook =?Utf-8?B?Um9iZXJ0?= Microsoft Excel Programming 2 6th Oct 2005 02:36 AM
activating opened form Alex Microsoft Access Form Coding 2 30th Jul 2004 09:08 PM
activating diff. worksheets in opened workbook AlexD Microsoft Access VBA Modules 4 22nd Apr 2004 06:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:44 PM.