![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Location: USA
Posts: 1,263
|
I have the following code saved in my workbook:
Private Sub Workbook_Open() Application.ScreenUpdating = False ChDir "S:TREND ANALYSIS" Workbooks.Open Filename:="S:TREND ANALYSISLINEAR TREND-ALL.XLS" ActiveWindow.ActivateNext Application.ScreenUpdating = True End Sub The code opens another workbook. The workbook that is being opened contains links to cells in the other workbook. What I need to do is modify this code so that it will: (1) Check first to see if the other file is already open, and if it is, to not execute the code. (2) Automatically update the links upon opening the workbook, instead of being prompted to do it. Any help is appreciated. Regards, Kevin [ This Message was edited by: kskinne on 2002-10-29 10:03 ] |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: May 2002
Posts: 63
|
Here's some code to check if a workbook is open.
Dim W As Object For Each W in Workbooks If W.Name = "MyFile.xls" Then {do something} Next W |
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
To avoid the update links box try opening the file as in the code below: -
Workbooks.Open Filename:="C:My DocumentsBook1.xls", UpdateLinks:=3 Strangely, Application.AsktoUpdateLinks = False doesn't work when placed in the Workbook_Open module. |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: May 2002
Posts: 63
|
To control link updating when you open a workbook through VBA, just add the update code you want after the name. For example:
Workbooks.Open "MyFile.xls", "0" 0 Doesn't update any references 1 Updates external references but not remote references 2 Updates remote references but not external references 3 Updates both remote and external references |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|