Force iteration in workbook

G

gump

I have a workbook that is shared and required iteration to be turned on for
the date calculations to work. How can I force this on everytime the
workbook is opened?
 
D

Dave Peterson

You could create a new workbook that changes the calculation mode and then opens
the workbook that you want.

After it's done it's work, the macro would close the new workbook.

Option Explicit
Sub Auto_Open()

Dim TempWkbk As Workbook
Dim Wkbk As Workbook
Dim IsThereAnActiveWork As Boolean

Set TempWkbk = Nothing
On Error Resume Next
Set TempWkbk = ActiveWorkbook
On Error GoTo 0

If TempWkbk Is Nothing Then
IsThereAnActiveWork = False
Set TempWkbk = Workbooks.Add(1)
Else
IsThereAnActiveWork = True
End If

With Application
.Calculation = xlManual
.MaxChange = 0.001
End With

Set Wkbk = Workbooks.Open(Filename:="c:\my documents\excel\book1.xls")

If IsThereAnActiveWork = True Then
'do nothing
Else
TempWkbk.Close savechanges:=False
End If

ThisWorkbook.Close savechanges:=False

End Sub

Then open this helper workbook instead of opening the real workbook.
 

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