如何使用 Excel VBA 打开文件并关闭更新链接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45641255/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to open a file using Excel VBA and turn off updating links
提问by JS Bach
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.
我目前有一个宏,我可以在其中打开另一个文件,复制数据,然后使用宏将数据粘贴到我的文件中。我复制数据的 Feeder 文件具有指向其他其他工作簿的链接。我如何让宏继续而不提示我更新链接。
Sub FeedFiles()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Workbooks.Open Filename:= _
"T:\Planning\FY Budget18 Budget\Director Templates\With updates18 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
采纳答案by Maciej Los
In A Short:
Workbooks.Open methodhas several parameters. One of them is UpdateLinks
which you have to set to false
.
简而言之:
Workbooks.Open 方法有几个参数。其中之一是UpdateLinks
您必须设置为false
。
Dim wbk As Workbook
Set wbk = Application.Workbooks.Open(FileName:="FullePathToExcelFile", UpdateLinks:=False)
Try! Good luck!
尝试!祝你好运!