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
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,143
Messages
5,599,975
Members
414,354
Latest member
Flaxarn

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