MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 6th, 2002, 03:12 PM   #1
jgoulart
Board Regular
 
Join Date: Feb 2002
Location: John G
Posts: 62
Default

I have an application that all of a suddend seems to take forever loading into excel. As a matter of fact there is even a fairly good size delay before the program prompts to allow or dissallow macros. How can I find out how to speed up the load time. I do have quite a bit of on workbook open processing but I don't think it is so much that it could be loading down the system. Any ideas would be appreciated. Here is a sample of what I am doing on workbook open:Private Sub Workbook_Open()
Dim test
Dim test2

Dim x
ActiveWorkbook.Unprotect Password:="2rsuccess"
setvars

Utl_BuildCmdBar "invtool", msoBarTop, Workbooks(fname).Sheets("menusheet").Range("cbdata"), fname

Application.ScreenUpdating = False

If Worksheets("invoice").Range("N:IV").EntireColumn.Hidden = False Then
Worksheets("invoice").Range("N:IV").EntireColumn.Hidden = True
End If

If Worksheets("invoice").Range("49:65536").EntireRow.Hidden = False Then
Worksheets("invoice").Range("49:65536").EntireRow.Hidden = True
End If

If Sheets("setup").Visible = True Then
Sheets("setup").Select
Sheets("setup").Visible = False
Sheets("setup").Visible = xlVeryHidden
End If

If Sheets("MenuSheet").Visible = True Then
Sheets("MenuSheet").Select
Sheets("MenuSheet").Visible = False
Sheets("MenuSheet").Visible = xlVeryHidden
End If

If Sheets("temp").Visible = True Then
Sheets("temp").Select
Sheets("temp").Visible = False
Sheets("temp").Visible = xlVeryHidden
End If

If Sheets("Nutritional Products").Visible = True Then
Sheets("Nutritional Products").Select
Sheets("Nutritional Products").Visible = False
Sheets("Nutritional Products").Visible = xlVeryHidden
End If

If Sheets("Personal Care").Visible = True Then
Sheets("Personal Care").Select
Sheets("Personal Care").Visible = False
Sheets("Personal Care").Visible = xlVeryHidden
End If

If Sheets("Colour Cosmetics").Visible = True Then
Sheets("Colour Cosmetics").Select
Sheets("Colour Cosmetics").Visible = False
Sheets("Colour Cosmetics").Visible = xlVeryHidden
End If

If Sheets("Literature").Visible = True Then
Sheets("Literature").Select
Sheets("Literature").Visible = False
Sheets("Literature").Visible = xlVeryHidden
End If

If Sheets("Art of Promotion").Visible = True Then
Sheets("Art of Promotion").Select
Sheets("Art of Promotion").Visible = False
Sheets("Art of Promotion").Visible = xlVeryHidden
End If


If Sheets("Sheet2").Visible = True Then
Sheets("sheet2").Select
Sheets("sheet2").Visible = False
Sheets("sheet2").Visible = xlVeryHidden
End If

If Sheets("Database").Visible = True Then
Sheets("Database").Select
Sheets("Database").Visible = False
Sheets("Database").Visible = xlVeryHidden
End If

If Sheets("Invoice Lookup").Visible = True Then
Sheets("Invoice Lookup").Select
Sheets("Invoice Lookup").Visible = False
Sheets("Invoice Lookup").Visible = xlVeryHidden
End If

If Sheets("Customer").Visible = True Then
Sheets("Customer").Select
Sheets("Customer").Visible = False
Sheets("Customer").Visible = xlVeryHidden
End If



If Sheets("Autofill").Visible = True Then
Sheets("Autofill").Select
Sheets("Autofill").Visible = False
Sheets("Autofill").Visible = xlVeryHidden
End If

If Sheets("Invoice").Visible = True Then
Sheets("Invoice").Select
Else
Sheets("Invoice").Visible = True
Sheets("Invoice").Select
End If

getsetup2
ActiveWorkbook.protect Password:="2rsuccess"
If CheckSysPass() = False Then
EnterPassword.Show
End If
clear
getdate
getnewinvoicenum
'drop = True
Sheets("sheet2").Range("invoice").Value = GetSetting(appname:=ThisWorkbook.name, section:="Startup", _
key:="Invoice", Default:="1000") + 1
Sheets("invoice").invcont = GetSetting(appname:=ThisWorkbook.name, section:="Startup", _
key:="Invoice", Default:="1000") + 1
'invcont = Sheets("sheet2").Range("invoice")
Application.ScreenUpdating = True


End Sub


Just to give you an example of the time on open it took about 15 seconds for the enable/disable macro prompt to come up and then it was another almost 1:30 min before it actually opened. Any ideas would be much appreciated.

John

jgoulart is offline   Reply With Quote
Old Apr 6th, 2002, 05:52 PM   #2
Jay Petrulis
MrExcel MVP
 
Jay Petrulis's Avatar
 
Join Date: Mar 2002
Location: Chicago, IL USA
Posts: 2,042
Default

Hi John,

1. Try deleting all the files in your temp directory (just a guess here).

2. Rob Bovey, in the following thread: http://groups.google.com/groups?hl=e...rldnet.att.net

Suggests to wait a fraction of time when Excel opens to allow its native "garrbage cleanup" utility to kick in and clean house before any automatic macros are executed.

(By the way, Rob Bovey is an Excel guru who knows more about Excel and Excel VBA than you or I could ever possibly hope to know.)

So, following his suggestions, I recommend moving the routine from the workbook_open in the ThisWorkbook module to an Auto_Open routine in a standard module.

Also, you can speed up the code by removing all .select statements.

The following should execute faster.

------------------------
Sub Auto_Open()
Application.OnTime Now(), "AppAutoOpen"
End Sub

Sub AppAutoOpen()
''' Run application startup code here.

Dim test
Dim test2

Dim x
ActiveWorkbook.Unprotect Password:="2rsuccess"
setvars ' ???? wasn't dimmed, through error

Utl_BuildCmdBar "invtool", msoBarTop, Workbooks(fname).Sheets("menusheet").Range("cbdata"), fname

Application.ScreenUpdating = False

Worksheets("invoice").Range("N:IV").EntireColumn.Hidden = True
Worksheets("invoice").Range("49:65536").EntireRow.Hidden = True

If Sheets("setup").Visible = True Then Sheets("setup").Visible = xlVeryHidden
If Sheets("MenuSheet").Visible = True Then Sheets("MenuSheet").Visible = xlVeryHidden
If Sheets("temp").Visible = True Then Sheets("temp").Visible = xlVeryHidden
If Sheets("Nutritional Products").Visible = True Then Sheets("Nutritional Products").Visible = xlVeryHidden
If Sheets("Personal Care").Visible = True Then Sheets("Personal Care").Visible = xlVeryHidden
If Sheets("Colour Cosmetics").Visible = True Then Sheets("Colour Cosmetics").Visible = xlVeryHidden
If Sheets("Literature").Visible = True Then Sheets("Literature").Visible = xlVeryHidden
If Sheets("Art of Promotion").Visible = True Then Sheets("Art of Promotion").Visible = xlVeryHidden
If Sheets("Sheet2").Visible = True Then Sheets("sheet2").Visible = xlVeryHidden
If Sheets("Database").Visible = True Then Sheets("Database").Visible = xlVeryHidden
If Sheets("Invoice Lookup").Visible = True Then Sheets("Invoice Lookup").Visible = xlVeryHidden
If Sheets("Customer").Visible = True Then Sheets("Customer").Visible = xlVeryHidden
If Sheets("Autofill").Visible = True Then Sheets("Autofill").Visible = xlVeryHidden
Sheets("Invoice").Visible = True
Sheets("Invoice").Select

getsetup2
ActiveWorkbook.Protect Password:="2rsuccess"
If CheckSysPass() = False Then
EnterPassword.Show
End If
Clear
getdate
getnewinvoicenum
'drop = True
Sheets("sheet2").Range("invoice").Value = GetSetting(appname:=ThisWorkbook.Name, section:="Startup", _
key:="Invoice", Default:="1000") + 1
Sheets("invoice").invcont = GetSetting(appname:=ThisWorkbook.Name, section:="Startup", _
key:="Invoice", Default:="1000") + 1
'invcont = Sheets("sheet2").Range("invoice")
Application.ScreenUpdating = True
End Sub
---------------------------

Also, if you want the sheets hidden, you don't really need to test if they are visible.

You could possibly accomplish the same thing with

Dim ws As Worksheet

Sheets("Sheet1").Visible = True
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Sheet1" Then ws.Visible = xlSheetVeryHidden
Next ws


HTH,
Jay
Jay Petrulis is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 08:57 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes