Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / February 2008

Tip: Looking for answers? Try searching our database.

personal.xls : hide with XLApp statement ???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don - 05 Feb 2008 22:19 GMT
I've got the following code in personal.xls (ThisWorkbook) to set calculation
to automatic and set iterations to true.  Code works great...but I'd like to
insert some additional code to make personal.xls hide itself.  I was thinking
perhaps another XLApp statement added somewhere below...but I haven't a clue.
Any suggestions?  Thanks.

Private WithEvents XLApp As Excel.Application

Private Sub Workbook_Open()
Set XLApp = Excel.Application
End Sub

Private Sub XLApp_NewWorkbook(ByVal Wb As Workbook)
XLApp.Calculation = xlCalculationAutomatic
XLApp.Iteration = True
XLApp.MaxIterations = 9999
End Sub

Private Sub XLApp_WorkbookOpen(ByVal Wb As Workbook)
XLApp.Calculation = xlCalculationAutomatic
XLApp.Iteration = True
XLApp.MaxIterations = 9999
End Sub
Dave Peterson - 05 Feb 2008 22:36 GMT
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.

> I've got the following code in personal.xls (ThisWorkbook) to set calculation
> to automatic and set iterations to true.  Code works great...but I'd like to
[quoted text clipped - 19 lines]
> XLApp.MaxIterations = 9999
> End Sub

Signature

Dave Peterson

Don - 05 Feb 2008 23:04 GMT
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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.