ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UpdateLinks (https://www.excelbanter.com/excel-programming/340245-updatelinks.html)

Howard Kaikow

UpdateLinks
 
I want to avoid the update links message when a workbook is opened, but
only for that workbook.

So I created a module with the code below.
However Auto_open is run AFTER the update links dialog appears.
I also tried using Workbook_Open.

How do I stop the dialog from appearing?
I do want to update every time this workbook is opened.

Public Sub Auto_Open()
Application.AskToUpdateLinks = False
End Sub

Public Sub Auto_Close()
Application.AskToUpdateLinks = True
End Sub


--
http://www.standards.com/; See Howard Kaikow's web site.



Cush

UpdateLinks
 
I recently used this code and found it equivalent to ToolsOptionsEdit and
unchecking the "Ask to update links automatically"

But it triggered after the wbk was opened, as you have found ( whether I put
it in Wbk_Open or Auto_Open). Hence, I did not turn it off during wbk_close

The result is that on all subsequent Excel sessions, with this wbk or
others, I was not hassled with the dialog. (Which was fine with me, as I
don't have any use where I would open a workbook that I don't want updated.)

"Howard Kaikow" wrote:

I want to avoid the update links message when a workbook is opened, but
only for that workbook.

So I created a module with the code below.
However Auto_open is run AFTER the update links dialog appears.
I also tried using Workbook_Open.

How do I stop the dialog from appearing?
I do want to update every time this workbook is opened.

Public Sub Auto_Open()
Application.AskToUpdateLinks = False
End Sub

Public Sub Auto_Close()
Application.AskToUpdateLinks = True
End Sub


--
http://www.standards.com/; See Howard Kaikow's web site.




Norman Jones

UpdateLinks
 
Hi Howard,

If you are opening the workbook programmatically, try:

Sub Tester()
Workbooks.Open "MyBook.xls", UpdateLinks:=True
End Sub

If the workbook is to be opened manually, consider using a dummy workbook.
In the dummy book include the code:

Private Sub Workbook_Open()
Workbooks.Open "MyBook.xls", UpdateLinks:=True
ThisWorkbook.Close SaveChanges:=False
End Sub

---
Regards,
Norman



"Howard Kaikow" wrote in message
...
I want to avoid the update links message when a workbook is opened, but
only for that workbook.

So I created a module with the code below.
However Auto_open is run AFTER the update links dialog appears.
I also tried using Workbook_Open.

How do I stop the dialog from appearing?
I do want to update every time this workbook is opened.

Public Sub Auto_Open()
Application.AskToUpdateLinks = False
End Sub

Public Sub Auto_Close()
Application.AskToUpdateLinks = True
End Sub


--
http://www.standards.com/; See Howard Kaikow's web site.





Howard Kaikow

UpdateLinks
 
"Norman Jones" wrote in message
...
Hi Howard,

If you are opening the workbook programmatically, try:

Sub Tester()
Workbooks.Open "MyBook.xls", UpdateLinks:=True
End Sub

If the workbook is to be opened manually, consider using a dummy workbook.
In the dummy book include the code:

Private Sub Workbook_Open()
Workbooks.Open "MyBook.xls", UpdateLinks:=True
ThisWorkbook.Close SaveChanges:=False
End Sub


That may work, but then I'd need a dummy workbook to correspond to each
workbook for which this is an issue.

I was thinking of trying a BeforeXXX event, if I can find one that executes
before the dialog.
Or maybe an Activate event?



Norman Jones

UpdateLinks
 
Hi Howard,

I was thinking of trying a BeforeXXX event, if I can find one that
executes
before the dialog.
Or maybe an Activate event?


I doubt that this will be fruitful.

At: http://www.cpearson.com/excel/events.htm

Chip Pearson lists the order of event Procedures as:

'=================================

When opening a workbook, the order of events is as follows:

1. Workbook_Open
2. App_WorkbookOpen
3. Workbook_WindowDeactivate (of previous workbook)
4. App_WindowDeactivate (of prevous workbook)
5. Workbook_Deactivate (of previous workbook)
6. Workbook_Activate
7. App_WorkbookActivate
8. Workbook_WindowActivate
9. App_WindowActivate
10. Auto_Open

'=================================
---
Regards,
Norman

"Howard Kaikow" wrote in message

That may work, but then I'd need a dummy workbook to correspond to each
workbook for which this is an issue.

I was thinking of trying a BeforeXXX event, if I can find one that
executes
before the dialog.
Or maybe an Activate event?




Howard Kaikow

UpdateLinks
 
"Norman Jones" wrote in message
...
Hi Howard,

I was thinking of trying a BeforeXXX event, if I can find one that
executes
before the dialog.
Or maybe an Activate event?


I doubt that this will be fruitful.


Ayup, it was not fruitful.

Easiest may be to write a VB 6 program that presents a list of the affected
workbooks(currently just one), then put a shortcut to that .exe where
useful.

Since there is only 1 workbook affected now, i may just have the vb program
do the open.



Dave Peterson

UpdateLinks
 
The bad news is that the links are handled before any code (in that workbook)
starts running.

Maybe you could create a dummy workbook that allows the user to pick the
workbook to open.



Howard Kaikow wrote:

"Norman Jones" wrote in message
...
Hi Howard,

If you are opening the workbook programmatically, try:

Sub Tester()
Workbooks.Open "MyBook.xls", UpdateLinks:=True
End Sub

If the workbook is to be opened manually, consider using a dummy workbook.
In the dummy book include the code:

Private Sub Workbook_Open()
Workbooks.Open "MyBook.xls", UpdateLinks:=True
ThisWorkbook.Close SaveChanges:=False
End Sub


That may work, but then I'd need a dummy workbook to correspond to each
workbook for which this is an issue.

I was thinking of trying a BeforeXXX event, if I can find one that executes
before the dialog.
Or maybe an Activate event?


--

Dave Peterson

Howard Kaikow

UpdateLinks
 
I ended up using a dummy workbook with the following

Private Sub Workbook_Open()
Dim wbk As Excel.Workbook
Set wbk = Workbooks.Open(StringForPathToRealWorkbook, UpdateLinks:=True)
wbk.Save
Set wbk = Nothing
ThisWorkbook.Close savechanges:=False
End Sub


If I ever feel a need to do this for more than 1 workbook, I'll create a VB
6 .exe to handle all the workbooks.



Lonnie M.

UpdateLinks
 
I was just asked this question by a coworker and I tried the following
code, which worked for our purposes. I understand that the 'update
links' fires before the 'Workbook_Open' code is run, but the links
are remote for the end users of this document and they are not prompted
to 'Update Links', 'Continue', or 'Edit' links.

Public Sub Workbook_Open()
If Application.Version = "11.0" Then
Application.DisplayAlerts = False
Application.AskToUpdateLinks = False
Application.DisplayAlerts = True
End If
End Sub

Then I got to thinking about what was really happening above and I
tried this with the same result:

Public Sub Workbook_Open()
Application.DisplayAlerts = False
Application.DisplayAlerts = True
End Sub

It worked for my needs--it may not be the right solution every time.

Regards--Lonnie M.



All times are GMT +1. The time now is 02:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com