Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 144
Default Code exected at "Workbook Open" slowing/stopping file from opening

Hi all,

I'm in process of completing a spreadsheet with a lot of custom macros that
will be used by a lot of different people. Some of the macros require the
"Analysis Toolpak" and "Solver" add-ins. As a result, I have the two subs
below executing at "Workbook_Open" (they are the same macro really, one
specific to "Analysis Toolpak" and one specific to "Solver").

The issue I'm having is that over time, it takes longer and longer to open -
sometimes it just freezes up. When it freezes up, I use Task Manager to
close Excel -- when I try to open the file again, Vista (my OS) recommends
that I don't add in Solver or Analysis Toolpak as they caused a serious error
the last time I attempted to open the file. Wondering if anyone knows what
exactly in the code would be causing the issue and/or how to get around it?

FYI - when I used "Code Cleaner"
(http://www.appspro.com/Utilities/CodeCleaner.htm), this restores the file to
openinig quickly again. However, within 20 times of opening the file, the
issue resurfaces.

Also, the code for the add-ins was taken from the "Peltier Technical
Services" website (http://peltiertech.com/Excel/SolverVBA.html).

Code:
-----------------------------
Private Sub Workbook_Open()

Module22.CheckSolver
Module22.CheckAntoolpak

End Sub
-----------------------------
Public Function CheckSolver() As Boolean
'' Adjusted for Application.Run() to avoid Reference problems with Solver
'' Peltier Technical Services, Inc., Copyright © 2007. All rights reserved.
'' Returns True if Solver can be used, False if not.

Dim bSolverInstalled As Boolean

If gbDebug Then Debug.Print Now, "CheckSolver "
'' Assume true unless otherwise
CheckSolver = True

On Error Resume Next
' check whether Solver is installed
bSolverInstalled = Application.AddIns("Solver Add-In").Installed
Err.Clear

If bSolverInstalled Then
' uninstall temporarily
Application.AddIns("Solver Add-In").Installed = False
' check whether Solver is installed (should be false)
bSolverInstalled = Application.AddIns("Solver Add-In").Installed
End If

If Not bSolverInstalled Then
' (re)install Solver
Application.AddIns("Solver Add-In").Installed = True
' check whether Solver is installed (should be true)
bSolverInstalled = Application.AddIns("Solver Add-In").Installed
End If

If Not bSolverInstalled Then
MsgBox "Solver not found. This workbook will not work.", vbCritical
CheckSolver = False
End If

If CheckSolver Then
' initialize Solver
Application.Run "Solver.xla!Solver.Solver2.Auto_open"
End If

On Error GoTo 0

End Function
----------------------------------------
Public Function CheckAntoolpak() As Boolean
'' Adjusted for Application.Run() to avoid Reference problems with
Analysis ToolPak
'' Peltier Technical Services, Inc., Copyright © 2007. All rights reserved.
'' Returns True if Analysis ToolPak can be used, False if not.

Dim bantoolpakInstalled As Boolean

If gbDebug Then Debug.Print Now, "Checkantoolpak "
'' Assume true unless otherwise
CheckAntoolpak = True

On Error Resume Next
' check whether Analysis ToolPak is installed
bantoolpakInstalled = Application.AddIns("Analysis ToolPak").Installed
Err.Clear

If bantoolpakInstalled Then
' uninstall temporarily
Application.AddIns("Analysis ToolPak").Installed = False
' check whether Analysis ToolPak is installed (should be false)
bantoolpakInstalled = Application.AddIns("Analysis ToolPak").Installed
End If

If Not bantoolpakInstalled Then
' (re)install Analysis ToolPak
Application.AddIns("Analysis ToolPak").Installed = True
' check whether Analysis ToolPak is installed (should be true)
bantoolpakInstalled = Application.AddIns("Analysis ToolPak").Installed
End If

If Not bantoolpakInstalled Then
MsgBox "Analysis ToolPak not found. This workbook will not work.",
vbCritical
CheckAntoolpak = False
End If

If CheckAntoolpak Then
' initialize Analysis ToolPak
Application.Run "Analysis ToolPak.xla!Analysis ToolPak.Auto_open"
End If

On Error GoTo 0

End Function

--
Robert
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Excel Discussion (Misc queries) 0 April 23rd 09 08:53 PM
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Setting up and Configuration of Excel 0 April 23rd 09 08:53 PM
"compatability mode" this is slowing things, how to fix jammon Excel Discussion (Misc queries) 1 October 17th 08 04:35 PM
On opening Excel, 4 non ".xls" files open that I cannot delete Twoheat Excel Discussion (Misc queries) 2 March 6th 06 02:36 PM
Problem- Recording macros for "file save" and "File open" tritaco Excel Programming 1 April 22nd 04 06:15 PM


All times are GMT +1. The time now is 09:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"