Turn Off Calcs in Excel

tuktuk

Well-known Member
Joined
Nov 13, 2006
Messages
856
I am running some code that export qry result to an excel application but want to turn off the "Application.Calculation" in excel prior to the export.

i cannot figure out the correct syntax.

here is the portion of the modules code definin my Excel app, workbook worksheet etc.

Code:
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim blnEXCEL As Boolean, blnHeaderRow As Boolean

blnEXCEL = False

' Replace True with False if you do not want the first row of
' the worksheet to be a header row (the names of the fields
' from the recordset)
blnHeaderRow = False

' Establish an EXCEL application object
On Error Resume Next
Set xlx = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
      Set xlx = CreateObject("Excel.Application")
      blnEXCEL = True
End If
Err.Clear
On Error GoTo 0

' Change True to False if you do not want the workbook to be
' visible when the code is running
xlx.Visible = True

i've tried
Code:
'turn off calcs
excel.Application.Calculation = xlManual

and

Code:
xlx.Calculation = xlManual

thanks for the help
Tuk
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
The problem with this:

'turn off calcs
excel.Application.Calculation = xlManual

is that you are trying to use an EXCEL CONSTANT with late binding and you can't do it exactly that way. You also should not be using excel.Application at all. That will open a hidden instantiated copy of Excel which will cause you grief until you close your database.

See my article here for more about that.


So, I don't know if the code is correct but you would reference this like this:

Code:
xlx.Application.Calculation = -4105

There might be a way to reference the constant in late binding but I've not used it.
 
Upvote 0
this appears to have solved the issue

Code:
Set xlw = xlx.Workbooks.Open(theFullPath & "Template_Subnet_Specific.xls")

'turn off calcs
xlw.Application.Calculation = xlManual

i'll continue to research the topic on the suggested site.

i appreciate the help
 
Upvote 0

Forum statistics

Threads
1,215,159
Messages
6,123,346
Members
449,097
Latest member
thnirmitha

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
Back
Top