ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   turning off automatic calculation when loading VBA add-in (https://www.excelbanter.com/excel-programming/343195-turning-off-automatic-calculation-when-loading-vba-add.html)

Lars Schouw

turning off automatic calculation when loading VBA add-in
 
I want to turn of automatic calculation in Excel from my add-in
and have put the following code in the ThisWorkbook module.

Private Sub Workbook_Open()

Application.Calculation = xlCalculationAutomatic
End Sub


When starting Excel and there by loading the add-in I get the following
error:

Method 'Calculation' of object '_Application' failed

I seems to be the problem?

Lars


Lars Schouw

turning off automatic calculation when loading VBA add-in
 
Found a solution

ThisWorkbook.Activate
Application.Calculation = xlCalculationManual

because:
You need to have a workbook active before you can set the Calculation
property and although it seems counterintuitive, you can "activate"
your
add-in workbook to serve this purpose even though it's not visible.
You need to have a workbook active before you can set the Calculation
property and although it seems counterintuitive, you can "activate"
your
add-in workbook to serve this purpose even though it's not visible.

Source:http://www.excelforum.com/archive/in.../t-260962.html

Thanks
Lars



All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com