简体   繁体   English

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

[英]How to open a file using Excel VBA and turn off updating links

I currently have a macro where I open up another file, copy data, and paste the data in my file with macro. 我目前有一个宏,可以在其中打开另一个文件,复制数据并使用宏将数据粘贴到文件中。 The feeder file where I copy the data has links to other other workbooks. 我将数据复制到的供稿器文件具有指向其他其他工作簿的链接。 How would I have the macro continue without prompting me to update links. 我如何继续执行宏而不提示我更新链接。

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

In A Short: Workbooks.Open method has several parameters. 简而言之: Workbooks.Open方法具有多个参数。 One of them is UpdateLinks which you have to set to false . 其中之一是UpdateLinks ,您必须将其设置为false

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

Try! 尝试! Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM