MrExcel Message Board

PDF to Excel


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Notices

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 Jan 7th, 2004, 11:14 AM   #1
neilb
Board Regular
 
Join Date: Apr 2002
Posts: 128
Default summary sheets

Hi

I have a summary sheet that will be taking data from different weekly spreadsheets currently using formulas.

The problems is that alot of the weekly spreadsheets are not created yet so when you open the spreadsheet it keeps asking you to check each link. There is 52 * 12 links!!

Is there a better way to do this? or a macro that I can use to do this as it opens?

Any help would be much appreciated.
neilb is offline   Reply With Quote
Old Jan 7th, 2004, 11:19 AM   #2
santeria
Board Regular
 
santeria's Avatar
 
Join Date: Oct 2003
Location: Tallahassee
Posts: 1,844
Default Re: summary sheets

Have you created links to existing or non-existing files ?

__________________
"Don't Ruin an Apology with an Excuse"...
santeria is offline   Reply With Quote
Old Jan 7th, 2004, 11:30 AM   #3
neilb
Board Regular
 
Join Date: Apr 2002
Posts: 128
Default Re: summary sheets

non existing files for each week of 2004
neilb is offline   Reply With Quote
Old Jan 7th, 2004, 11:56 AM   #4
Andrew Poulsom
MrExcel MVP
Moderator
 
Andrew Poulsom's Avatar
 
Join Date: Jul 2002
Posts: 51,243
Default Re: summary sheets

Choose Tool|Options|Edit tab and check Ask to update automatic links. When you open the target workbook you will be prompted to update the links. If you choose No you won't get the File Not Found dialog box.

You can use this code to update the links to the workbooks that exist:

Code:
Sub UpdateLinks()
    Dim Links As Variant
    Dim i As Integer
    Dim Link As String
    Links = ActiveWorkbook.LinkSources
    If Not IsEmpty(Links) Then
        For i = 1 To UBound(Links)
            If FileExists(Links(i)) Then
                ThisWorkbook.UpdateLink Name:=Links(i), Type:=xlExcelLinks
            End If
        Next i
    End If
End Sub

Private Function FileExists(fname) As Boolean
'   Returns TRUE if the file exists
    Dim x As String
    x = Dir(fname)
    If x <> "" Then FileExists = True _
        Else FileExists = False
End Function
Andrew Poulsom is offline   Reply With Quote
Old Jan 7th, 2004, 11:59 AM   #5
Greg Truby
MrExcel MVP
Int'l Moderator
 
Greg Truby's Avatar
 
Join Date: Jun 2002
Location: 39° 17' 15" N, -94° 40' 26" W
Posts: 9,669
Default Re: summary sheets

Andrew,

I was looking at this one. I saw some constants in the Object Browser, namely XlLinkStatus, xlLinkStatusMissingFile and xlLinkStatusMissingSheet. But I can't for the life of me figure out where they get used. Any idea where these constants come into play?
__________________
Greg
………………………………………………
Work: XL 2003, 2007 and 2010 on Windows 7
Please use CODE tags - especially for longer excerpts of code.
Greg Truby is offline   Reply With Quote
Old Jan 7th, 2004, 12:01 PM   #6
santeria
Board Regular
 
santeria's Avatar
 
Join Date: Oct 2003
Location: Tallahassee
Posts: 1,844
Default Re: summary sheets

Can you create "shell" files to get around the file not found issue ?

Might even help in building up a macro if you structure your files now, say... choose if you want the weekly files in one directory, or do you want a breakdown of Monthly, Quarterly, etc... Kind of pre-planning the directory infrastructure...

__________________
"Don't Ruin an Apology with an Excuse"...
santeria is offline   Reply With Quote
Old Jan 7th, 2004, 12:10 PM   #7
Andrew Poulsom
MrExcel MVP
Moderator
 
Andrew Poulsom's Avatar
 
Join Date: Jul 2002
Posts: 51,243
Default Re: summary sheets

Quote:
Originally Posted by Greg Truby
Andrew,

I was looking at this one. I saw some constants in the Object Browser, namely XlLinkStatus, xlLinkStatusMissingFile and xlLinkStatusMissingSheet. But I can't for the life of me figure out where they get used. Any idea where these constants come into play?
Greg,

Don't know - I don't have those constants in Excel 2000.

I imagine they can be used as arguments in some updated method. Tyr searching Help.
Andrew Poulsom is offline   Reply With Quote
Old Jan 7th, 2004, 12:18 PM   #8
neilb
Board Regular
 
Join Date: Apr 2002
Posts: 128
Default Re: summary sheets

I have already created the folder structure so that the main folder holds summary sheet is in its own folder and each weeks data is in its own folder. Like

Main folder - Summary
- Week 1
- Week 2
etc

With that vba (being a novice) can I put this in so that when the book is opened it will automaticaly update with no questions?

I don't really want to create a load of empty workbooks in each week as I have access automatically sending them across?

Many thanks

Many thanks
neilb is offline   Reply With Quote
Old Jan 7th, 2004, 12:25 PM   #9
Andrew Poulsom
MrExcel MVP
Moderator
 
Andrew Poulsom's Avatar
 
Join Date: Jul 2002
Posts: 51,243
Default Re: summary sheets

You can run it from the Workbook_Open event procedure, like this:

Code:
Private Sub Workbook_Open()
   Call UpdateLinks
End Sub
Andrew Poulsom is offline   Reply With Quote
Old Jan 7th, 2004, 12:53 PM   #10
Greg Truby
MrExcel MVP
Int'l Moderator
 
Greg Truby's Avatar
 
Join Date: Jun 2002
Location: 39° 17' 15" N, -94° 40' 26" W
Posts: 9,669
Default Re: summary sheets

Andrew - VBA help was not very helpful. Not much assistance if one's starting point is a constant. But by guessing based on the few clues offered in help on the LinkInfo method I sussed it out. Not really helpful here since you've already got this one resolved in a manner that doesn't rely on something only in XL2002, but here's where they came into play:

Sub LinkStatusTest()
****Dim strMsg As String, strLinkStats(10) As String, lsLinkStatus As XlLinkStatus
****
****strLinkStats(0) = "OK"
****strLinkStats(1) = "Missing File"
****strLinkStats(2) = "Missing Sheet"
****strLinkStats(3) = "Old (Not Updated)"
****strLinkStats(4) = "Source Not Calc'd"
****strLinkStats(5) = "Indeterminate"
****strLinkStats(6) = "Not Started"
****strLinkStats(7) = "Invalid Name"
****strLinkStats(8) = "Source Not Open"
****strLinkStats(9) = "Source Open"
****strLinkStats(10) = "Copied Values"
****
****alinks = ActiveWorkbook.LinkSources(XlLink.xlExcelLinks)
****If IsEmpty(alinks) Then Exit Sub
****For i = 1 To UBound(alinks)
********strMsg = strMsg & "Link " & i & ":" & vbTab & alinks(i) & vbCr
****Next i
****MsgBox strMsg
****strMsg = ""
****For i = 1 To UBound(alinks)
********strMsg = "Link " & i & ":" & vbTab & alinks(i) & vbCr & vbCr
********lsLinkStatus = ActiveWorkbook.LinkInfo(alinks(i), xlLinkInfoStatus)
********strMsg = strMsg & strLinkStats(lsLinkStatus)
********MsgBox strMsg
****Next i
End Sub
__________________
Greg
………………………………………………
Work: XL 2003, 2007 and 2010 on Windows 7
Please use CODE tags - especially for longer excerpts of code.
Greg Truby 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:56 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