VBA xlCalculationManual trips error when called App_WorkbookOpen

jscranton

Well-known Member
Joined
May 30, 2011
Messages
707
I am trying to change the application settings to xlCalculationManual when opening up a workbook. However, this code throws an error if a workbook is already set to xlCalculationManual (Error: Method 'Calculation' of object'_Application' failed). It does not throw the error if the setting is xlCalculationAutomatic

Code:
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)

    Application.Calculation = xlCalculationManual

End Sub

I tried instead to add a condition in another routine but I am getting very strange results. The "Change Settings" macro runs fine except when called by the WorkbookOpen procedure. Then I get a type mismatch error. If it matters, all of this is part of an excel add-in for an end user. :confused::oops:



Code:
Private Sub App_WorkbookOpen(ByVal Wb As Workbook)

    Call changeSettings
End Sub
_____
Sub changeSettings()
 
 If Application.Calculation <> xlCalculationManual Then Application.Calculation = xlCalculationManual
 If Application.CalculateBeforeSave = True Then Application.CalculateBeforeSave = False


End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

jscranton

Well-known Member
Joined
May 30, 2011
Messages
707
Solved.

Apparently, you have to change the setting here:

Code:
Private Sub Workbook_Open()
        Set App = Application
	Application.Calculation = xlCalculationManual
	Application.CalculateBeforeSave = False
End Sub

Rather than in the "Private Sub App_WorkbookOpen" module.

I am sure someone can explain why but wanted to close this in case future users had the same issue.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,993
Messages
5,856,695
Members
431,828
Latest member
kARTIK12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top