I'm saving my updates in my workbook automatically to a new template:
However, Excel always asks me if I want to clear external data and refresh it after template is opened:
However, I cannot automate this behaviour (
But if I use
, then the dialog appears again when saving the template.
I can suppress the dialog (it won't show up), but the Excel understands it as
I also tried to deactivate updating external contents/links before saving the template but none of these help:
Would you know how to suppress the dialog in question and answer it as
Btw, this question is follow up of my original question on StackOverflow. But this new question is more difficult and you guys here seem to be much more technically skilled in Excel then SO users
VBA Code:
Application.ActiveWorkbook.SaveAs fileToSave, xlOpenXMLTemplateMacroEnabled
However, Excel always asks me if I want to clear external data and refresh it after template is opened:
I don't want Excel to clear external data (I'm clearing them by myself before saving a new template) and update them after opening the template. Therefore the expected answer isThis workbook contains external data. Do you want Microsoft Excel to clear the data before saving the template, and then automatically refresh the data whenever the template is opened?
Yes
No
Cancel
No
.However, I cannot automate this behaviour (
No
answer) in VBA. I can simulate only Yes
answer using the code below:
VBA Code:
Application.ActiveWorkbook.TemplateRemoveExtData = True
Application.ActiveWorkbook.SaveAs fileToSave, xlOpenXMLTemplateMacroEnabled
But if I use
VBA Code:
Application.ActiveWorkbook.TemplateRemoveExtData = False
False
is simply ignore.I can suppress the dialog (it won't show up), but the Excel understands it as
Yes
answer anyway.
VBA Code:
Application.DisplayAlerts = False
Application.ActiveWorkbook.TemplateRemoveExtData = True
Application.ActiveWorkbook.SaveAs fileToSave, xlOpenXMLTemplateMacroEnabled
I also tried to deactivate updating external contents/links before saving the template but none of these help:
VBA Code:
ActiveWorkbook.UpdateRemoteReferences = False
ActiveWorkbook.UpdateLinks = xlUpdateLinksNever
Would you know how to suppress the dialog in question and answer it as
No
(i.e. without clearing the date and updating later when template is opened)? Thanks.Btw, this question is follow up of my original question on StackOverflow. But this new question is more difficult and you guys here seem to be much more technically skilled in Excel then SO users