PDA

View Full Version : Simple code that refreshes link to another excel file with Password



piflechien73
11-24-2022, 07:41 AM
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 :-)

June7
11-24-2022, 11:28 AM
See if this helps https://access-excel.tips/excel-vba-refresh-closed-workbook/#:~:text=Excel%20refresh%20closed%20workbook%20First%20of%20all%2C%20to,wha t%20kind%20of%20refresh%20you%20want%20to%20perform.

Grade4.2
12-09-2022, 02:47 AM
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.