如何使用Excel VBA打开文件并关闭更新链接

时间:2017-08-11 18:00:14

标签: excel vba excel-vba

我目前有一个宏,我打开另一个文件,复制数据,然后用宏将数据粘贴到我的文件中。我复制数据的馈送文件包含指向其他其他工作簿的链接。如何在不提示我更新链接的情况下继续宏。

Sub FeedFiles()

Application.DisplayAlerts = False
Application.ScreenUpdating = False

Workbooks.Open Filename:= _
    "T:\Planning\FY Budget\2018 Budget\Director Templates\With updates\2018 Budget PL_HC_CAP - Thomson_V2.xlsx" _
, Password:="Thomson18"
Workbooks("2018 Budget PL_HC_CAP -Thomson_V2.xlsx").Worksheets("Summary").Range("A1:AH227").Activate
Workbooks("2018 Budget PL_HC_CAP - Thomson_V2.xlsx").Worksheets("Summary").Range("A1:AH227").Copy
Workbooks("2018 Budget PL_HC_CAP - Total 802.xlsm").Worksheets("Thomson").Range("A1:AH227").PasteSpecial xlPasteValues
Workbooks("2018 Budget PL_HC_CAP - Thomson_V2.xlsx").Close

 Application.DisplayAlerts = True
 Application.ScreenUpdating = True
 End Sub

1 个答案:

答案 0 :(得分:0)

简而言之: Workbooks.Open method有几个参数。其中一个是UpdateLinks,您必须将其设置为false

Dim wbk As Workbook
Set wbk = Application.Workbooks.Open(FileName:="FullePathToExcelFile", UpdateLinks:=False)

尝试!祝你好运!