Hi everybody,

I have following code with changes the links in a workbook.

Sub WbThs_ChangeLink_Excel()
    Dim wbTrg As Workbook
    Dim sLinkNew As String
    Dim aLinks As Variant, vLink As Variant

        Application.ScreenUpdating = False

                
        myfilepath = Application.GetOpenFilename()
        
        
        sLinkNew = myfilepath   'Change as required

        Set wbTrg = ThisWorkbook   'Change as required

        Rem Set array with all excel links
        aLinks = ActiveWorkbook.LinkSources(xlExcelLinks)

        Rem Replace each excel Link
        If Not IsEmpty(aLinks) Then
            For Each vLink In aLinks
                wbTrg.ChangeLink Name:=vLink, NewName:=sLinkNew, Type:=xlExcelLinks

        Next: End If

        Application.ScreenUpdating = True
            
        End Sub
Due too problems with the sharepoint where the files I refer to are located, I need to open the file first before I change the link otherwise I receive an error in the data I search for.
If the files are opened first, the links work perfectly. So my question is, can the code be adapted so that the file I want to change the links too is opened first before the changelink?

I don't know if my question is clear as english is not my first language. To simplify:

I need the code to open windows explorer -> via explorer select a file too open -> once it is opened, the links in the source file need to change into the required path so that I can retrieve the needed data in the newly opened file.

The adaptation needed in the code is too advanced for me. So I hope someone can help me with this?

Thanks for your input.