Reputation: 1234
I have a macros that opens a file, makes changes and saves it under some other name. It does so many times. The problem is, the file has links to other files, so when my macros opens that file Excel generates a window that asks whether or not those links should be refreshed.
It interrupts macros and requires manual mouse click, which is something I'd really wish to avoid. Is there any way to ensure it wouldn't happen within macros?
I tried
Dim cn As WorkbookConnection
For Each cn In resultWorkbook.Connections
cn.Refresh
Next
But it didn't work - the windows keep appearing.
Upvotes: 0
Views: 42
Reputation: 53663
Include the UpdateLinks parameter when calling Workbooks.Open
. The UpdateLinks argument (emphasis added):
Specifies the way external references (links) in the file, such as the reference to a range in the Budget.xls workbook in the following formula
=SUM([Budget.xls]Annual!C10:C25)
, are updated. If this argument is omitted, the user is prompted to specify how links will be updated. For more information about the values used by this parameter, see the Remarks section. If Microsoft Excel is opening a file in the WKS, WK1, or WK3 format and the UpdateLinks argument is 0, no charts are created; otherwise Microsoft Excel generates charts from the graphs attached to the file.
Upvotes: 1