turning off automatic calculation when loading VBA add-in

L

Lars Schouw

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
 
L

Lars Schouw

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/index.php/t-260962.html

Thanks
Lars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top