I was looking at ways people close out Excel add-in files (XLA files) when working with VBA, because I'd like to forefully close an XLA file whenever a used workbook closes, because there have been hiccups here and there that I've known about since I've been here, and I hope closin the file will help.
In this thread on another site:
,
The OP eventually pulled together this script that he stated worked great for what he was doing, and that simply telling Excel to close the file did not work.
My question is: Can anyone vouch for this type setup working well or else can anyone think of any issues I might run into if I tried setting up workbooks to do this?
Furthermore, if that idea works, I think it would work EVEN better for me. When I first began working in my current job, I found instances where the "Test" version of an addin was being called by "production" workbooks when they should have been pulling in the "production" excel add-in file. So that caused all sorts of headaches. I've corrected all that I am aware of to date, but the above gave me (I think) a great idea: I can tell Excel to load the correct add-in based on the folder structure the opened Excel file lies within.
With all those thoughts together: Can anyone tell me this is a crazy idea and that it's more likely to blow up in my face rather than help?
Thanks for any thoughts
p.s.: Additional point of clarification. With my current setup, the XLA file is referenced within the VBE by files that use it. So I have to add a reference to the XLA file for each of the Excel files. If it's a file in test that is moved to production, then I must manually remove the .XLA test file, and then add the .XLA production file under Tools->References in the VBE.
"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
In this thread on another site:
,
The OP eventually pulled together this script that he stated worked great for what he was doing, and that simply telling Excel to close the file did not work.
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
AddIns("Custom Functions").Installed = False
End Sub
Private Sub Workbook_Open()
AddIns.Add Filename:=ThisWorkbook.Path & "\Custom Functions.xla"
AddIns("Custom Functions").Installed = True
End Sub
My question is: Can anyone vouch for this type setup working well or else can anyone think of any issues I might run into if I tried setting up workbooks to do this?
Furthermore, if that idea works, I think it would work EVEN better for me. When I first began working in my current job, I found instances where the "Test" version of an addin was being called by "production" workbooks when they should have been pulling in the "production" excel add-in file. So that caused all sorts of headaches. I've corrected all that I am aware of to date, but the above gave me (I think) a great idea: I can tell Excel to load the correct add-in based on the folder structure the opened Excel file lies within.
With all those thoughts together: Can anyone tell me this is a crazy idea and that it's more likely to blow up in my face rather than help?
Thanks for any thoughts
p.s.: Additional point of clarification. With my current setup, the XLA file is referenced within the VBE by files that use it. So I have to add a reference to the XLA file for each of the Excel files. If it's a file in test that is moved to production, then I must manually remove the .XLA test file, and then add the .XLA production file under Tools->References in the VBE.
"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57