问题
I am working with excel application(AddIn) in excel/c#, getting a circular reference error which disappears when I enable automatic recalculation through excel options.
But I want to set Automatic option as default when the file opens, but for some reason it wont let me just save the .xlsx
file as automatic option enabled. I found some articles stating that you have to have a personal.xlsx
file in your XLStart
folder with the desired settings which is used by other sheets as reference, which I created and all my local excel sheets works fine with automatic option by default except this one template (template.xlsx
). The template is used to populate data and it has 29 sheets in it. So I don't know if that's creating the problem.
So now when I open excel, it opens the personal.xlsx
first which has Automatic option enabled, but then, when the template.xlsx
opens the option changes to "manual". Then I have to manually change it to Automatic option every single time. But all other .xlsx
files in my PC opens in Automatic option by default.
How to fix this?
回答1:
As I found in MSDN :
The user can select the mode through the Excel menu system, or programmatically using VBA, COM, or the C API.
1) You can change the option for a specific range by this:
Just with VBA:
Range.Calculate (introduced in Excel 2000, changed in Excel 2007)
and
Range.CalculateRowMajorOrder (introduced in Excel 2007)
2) Change option for Active Worksheet
By Keystroke: : SHIFT + F9
--VBA:--
ActiveSheet.Calculate
--C API:--
xlcCalculateDocument
3) Change option for All Open Workbooks
By Keystroke: F9
--VBA:--
Application.Calculate
--C API:--
xlcCalculateNow
For More read this MSDN article
来源:https://stackoverflow.com/questions/8085598/force-excel-2007-to-open-in-automatic-calculation-mode-by-default