![]() |
Deleting or Disabling code in Excel
Hello. I have an excel template that contains code in the background. I
want to be able to either delete or disable the code when the user saves the template as a .xls file. Any ideas? I have tried putting a version of "delete code on save" function in the template, but then when I save the template - it deletes the template code, which I don't want. Thanks, Cathy |
Deleting or Disabling code in Excel
Try this event code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If SaveAsUI Then Application.EnableEvents = False End If End Sub Regards, Stefi €˛Cathy W€¯ ezt Ć*rta: Hello. I have an excel template that contains code in the background. I want to be able to either delete or disable the code when the user saves the template as a .xls file. Any ideas? I have tried putting a version of "delete code on save" function in the template, but then when I save the template - it deletes the template code, which I don't want. Thanks, Cathy |
Deleting or Disabling code in Excel
Hi Stefi. Thanks for your reply. I already have that event in my code to
change all forumlas to values before saving so I just added the If statement to that event, but it didn't work. I tried putting it before and after but didn't work. In my workbook_open event I have a code that calls an open diaglog box for the user to select a file so I think this is what has to be "disabled" or "deleted" on save. Thanks again. "Stefi" wrote: Try this event code: Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) If SaveAsUI Then Application.EnableEvents = False End If End Sub Regards, Stefi €˛Cathy W€¯ ezt Ć*rta: Hello. I have an excel template that contains code in the background. I want to be able to either delete or disable the code when the user saves the template as a .xls file. Any ideas? I have tried putting a version of "delete code on save" function in the template, but then when I save the template - it deletes the template code, which I don't want. Thanks, Cathy |
All times are GMT +1. The time now is 03:10 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com