How do I set Excel Calculation Options to Manual from code using Late Binding.

I have Excel workbooks with lots of formulas in them that I populate from Access Code. All the workbook templates are set to "Manual Calculation" but if the user has another Excel workbook open that is set to Automatic, the template switches to Automatic when it opens.

Is there a way to set it back to Manual before starting the populating? When it's manual, the program runs MUCH slower.

Thanks.
Buck_BeasomDatabase DesignerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kanti PrasadCommented:
Hi

If it is possible ask the users to go to Formulas and set the calculations to Manual for this file.

Excel will use the setting of the 1st opened file in a session. Hence, one option is to code to open a dummy excel in manual mode and through  it open, your excel file. This way your excel will take the manual settings of the opened dummy file.

 

 try the below by opening a macro and pasting the below code and if it dont help then you need to do the above

Private Sub Workbook_Open()
  Application.Calculation = xlManual
End Sub
0
Patrick MatthewsCommented:
With late binding, you can either define your own constants, or you can use the numeric values.  So you can do any of the following:


Sub foo()

    Const xlCalculationManual As Long = -4135
    Const xlCalculationAutomatic As Long = -4105

    'code goes here

    xlApp.Calculation = xlCalculationManual

    'more code

    xlApp.Calculation = xlCalculationAutomatic

End Sub

Open in new window


Sub foo()

    'code goes here

    xlApp.Calculation = -4135

    'more code

    xlApp.Calculation = -4105

End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Buck_BeasomDatabase DesignerAuthor Commented:
In my experience, "xl" commands that would be generated by recording an Excel Macro do not function when using late binding. I will try "objExcel.Calculation = -4135, as I have successfully used some other "-4###" to minimize an open Excel application once it is loaded. Will let you know the results.

Thanks.
0
Buck_BeasomDatabase DesignerAuthor Commented:
Worked perfectly.

Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.