Consulting

Results 1 to 7 of 7

Thread: Workbook OPEN Event Code - Update Links

  1. #1
    VBAX Expert
    Joined
    Dec 2007
    Posts
    522
    Location

    Workbook OPEN Event Code - Update Links

    Hi All,

    Is there a code to place in a Workbook_Open event code, to automatically update all links for that specific workbook, without prompting the user to select update or not update?

    Normally, I click NO to update links for any workbooks that I open repeatedly, as is perferable, though for this one particular workbook, I would like to update automatically upon opening without prompting the User for a YES or NO (i.e. Don't update links).

    Any help appreciated.

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Quote Originally Posted by xluser2007
    Hi All,

    Is there a code to place in a Workbook_Open event code, to automatically update all links for that specific workbook, without prompting the user to select update or not update?

    Normally, I click NO to update links for any workbooks that I open repeatedly, as is perferable, though for this one particular workbook, I would like to update automatically upon opening without prompting the User for a YES or NO (i.e. Don't update links).

    Any help appreciated.
    Try this in the thisworkbook module
    [VBA]Private Sub Workbook_Open()
    With ThisWorkbook
    .UpdateLinks = xlUpdateLinksAlways
    End With
    End Sub[/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    VBAX Expert
    Joined
    Dec 2007
    Posts
    522
    Location
    Hi Simon,

    many thanks for your interest.

    I tried that, but it still gave the update links dialog box. It appears that it throws this in-built dialog up before actually accessing the Workbook_open code.

    Do you get the same issue?

  4. #4
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    To be honest i didn't try it!, however you can try surronding it with
    [VBA]
    Private Sub Workbook_Open()
    Application.DisplayAlerts=False
    With ThisWorkbook
    .UpdateLinks = xlUpdateLinksAlways
    End With
    Application.DisplayAlerts=True
    End Sub
    [/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  5. #5
    VBAX Expert
    Joined
    Dec 2007
    Posts
    522
    Location
    Thanks Simon,

    That is a good idea, but unfortunately it does not work.

    It appears that that updatelinks form is triggerred before the workbook_OPEN event.

    Any other such ideas, I'm game!

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Are you opening this workbook from code, or just using standard Excel?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    More to Bob's query, if you are using the code i gave in one workbook and then consequently opening another from that workbook the code will not update the links or bypass the message in the newly opened workbook, the code would have to reside in the workbook you are calling.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •