Personally, I wouldn't bother using code.
Open excel (and personal.xls).
With personal.xls the activeworkbook
Windows|hide
Close excel. You'll be prompted to save personal.xls. Make sure you click yes.
Restart excel and test it out.
When I do what you suggest, I get a debug error next time I start up a
worksheet. So it seems to "break" the way the code works. When I
subsequently unhide the worksheet (personal.xls) and save it, close excel
then reopen with some file other than personal.xls, everything works fine.
If I can't hide it with code, that's fine, but I'd like to hide it if
possible, and for some reason, the solution below breaks the functionality.
Thanks for the suggestion.
> Personally, I wouldn't bother using code.
>
[quoted text clipped - 28 lines]
> > XLApp.MaxIterations = 9999
> > End Sub
Dave Peterson - 05 Feb 2008 23:50 GMT
Ahh.
You're right.
The problem is that there has to be an active/visible workbook to change the
calculation mode.
This may work better (not vigorously tested):
Option Explicit
Private WithEvents XLApp As Excel.Application
Private Sub Workbook_Open()
Set XLApp = Excel.Application
End Sub
Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook)
ChangeTheCalculationMode
End Sub
Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook)
ChangeTheCalculationMode
End Sub
Sub ChangeTheCalculationMode()
Dim TempWkbk As Workbook
If ActiveWorkbook Is Nothing Then
Application.EnableEvents = False
Set TempWkbk = Workbooks.Add(1)
Application.EnableEvents = True
End If
XLApp.Calculation = xlCalculationAutomatic
XLApp.Iteration = True
XLApp.MaxIterations = 9999
If TempWkbk Is Nothing Then
'do nothing
Else
TempWkbk.Close savechanges:=False
End If
End Sub
This seemed to work ok in xl2003.
> When I do what you suggest, I get a debug error next time I start up a
> worksheet. So it seems to "break" the way the code works. When I
[quoted text clipped - 40 lines]
> >
> > Dave Peterson

Signature
Dave Peterson
Bob Flanagan - 06 Feb 2008 03:05 GMT
Dave, why not use a ThisWorkbook.Activate instead of adding a new workbook?
Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
> Ahh.
>
[quoted text clipped - 87 lines]
>> >
>> > Dave Peterson
Dave Peterson - 06 Feb 2008 04:20 GMT
The OP wants to put the code in personal.xls and he also wants that workbook
hidden.
> Dave, why not use a ThisWorkbook.Activate instead of adding a new workbook?
>
[quoted text clipped - 98 lines]
> >
> > Dave Peterson

Signature
Dave Peterson
Don - 06 Feb 2008 16:55 GMT
I tried your code below, but personal.xls still stays open (visible) in the
background. Is there some other short subroutine I can add to the end of the
original code to close/hide personal.xls by name? Thanks for your ideas so
far, I appreciate the effort.
> Ahh.
>
[quoted text clipped - 79 lines]
> > >
> > > Dave Peterson
Dave Peterson - 06 Feb 2008 17:02 GMT
Did you hide personal.xls manually?
That part of the instruction didn't change.
> I tried your code below, but personal.xls still stays open (visible) in the
> background. Is there some other short subroutine I can add to the end of the
[quoted text clipped - 88 lines]
> >
> > Dave Peterson

Signature
Dave Peterson
Don - 06 Feb 2008 17:24 GMT
I didn't originally, but now after hiding, everything works great. Thanks
for your help...and patience.
> Did you hide personal.xls manually?
>
[quoted text clipped - 92 lines]
> > >
> > > Dave Peterson
Dave Peterson - 06 Feb 2008 18:52 GMT
Keep an eye on it. I didn't have trouble, but I didn't test too much.
> I didn't originally, but now after hiding, everything works great. Thanks
> for your help...and patience.
[quoted text clipped - 99 lines]
> >
> > Dave Peterson

Signature
Dave Peterson