Consulting

Results 1 to 3 of 3

Thread: Simple code that refreshes link to another excel file with Password

  1. #1

    Simple code that refreshes link to another excel file with Password

    Hello,

    I have a code that opens other files in order to update links. There is one password also.
    See below:

    Sub OpenTheTemplate()
    Dim filename As String
    Workbooks.Open (ThisWorkbook.Path & "" & Range("x16").Value & ".xlsx"), Password:="BT2023", writerespassword:="BT2023"
    End Sub

    I was wondering if there is one existing that just "refreshes" links instead of opening the files each time

    Many thanks for help :-)
    Last edited by Aussiebear; 11-24-2022 at 01:05 PM. Reason: Added code tags to supplied code

  2. #2
    VBAX Mentor
    Joined
    Nov 2022
    Location
    The Great Land
    Posts
    331
    Location
    How to attach file: Reading and Posting Messages (vbaexpress.com), click Go Advanced below post edit window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    VBAX Regular
    Joined
    May 2018
    Location
    Sydney
    Posts
    57
    Location
    Quote Originally Posted by piflechien73 View Post
    Hello,

    I have a code that opens other files in order to update links. There is one password also.
    See below:

    Sub OpenTheTemplate()
    Dim filename As String
    Workbooks.Open (ThisWorkbook.Path & "" & Range("x16").Value & ".xlsx"), Password:="BT2023", writerespassword:="BT2023"
    End Sub

    I was wondering if there is one existing that just "refreshes" links instead of opening the files each time

    Many thanks for help :-)
    Yes, there is a way to refresh links without opening the source files. In Excel, you can use the Workbook.UpdateLink method to update the links in a workbook.

    Here is an example of how you can use this method to update the links in the active workbook:

    Sub UpdateLinks()
        ' Update all links in the active workbook
        ActiveWorkbook.UpdateLink Name:=xlExcelLinks
    ' You can also specify the type of links to update
        ' For example, to update only the external links, use the following line of code:
        ' ActiveWorkbook.UpdateLink Name:=xlExternal
    End Sub

    Note that the Workbook.UpdateLink method will only update the links that are stored in the workbook. If the source files are not available, the links will not be updated and you will see an error message.
    Last edited by Aussiebear; 12-09-2022 at 03:41 AM. Reason: Added code tags to supplied code
    If you only ever do what you can , you'll only ever be what you are.

Posting Permissions

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