Excel宏快速更新链接

时间:2017-05-29 01:35:40

标签: vba

我有这个宏来根据用户输入更新外部源的链接,但它确实很慢。

我错过了什么吗?

Sub UpdateLink()
    Dim varNewLink As Variant
    Dim lnk As Variant
    Dim i As Integer
     'Application.ScreenUpdating = False
     ' get all links
    lnk = ActiveWorkbook.LinkSources(xlExcelLinks)

    If Not IsEmpty(lnk) Then
         ' prompt for the new file for the link
        varNewLink = Application.GetOpenFilename
         ' if user didn't cancel, refresh the link
        If varNewLink <> False Then
            For i = 1 To UBound(lnk)
                ActiveWorkbook.ChangeLink Name:=lnk(i), NewName:=varNewLink, _
                Type:=xlExcelLinks
            Next i
        End If
    End If

    'Application.ScreenUpdating = True
End Sub

0 个答案:

没有答案