Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is it possible to program saving the current workbook without the vba code ?
Regards & TIA |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Yes it is but it also very dangerous if you make an error. However, try this. Put this in 'ThisWorkbook' which calls the code that does the deletion Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Call DeleteCode End Sub Then this in a general module Sub DeleteCode() Prompt = "Are you certain that you want to delete all the VBA Code?" Proceed = MsgBox(Prompt, vbYesNo + vbQuestion) If Proceed = vbNo Then Exit Sub End If On Error Resume Next With ActiveWorkbook.VBProject For x = .VBComponents.Count To 1 Step -1 .VBComponents.Remove .VBComponents(x) Next x For x = .VBComponents.Count To 1 Step -1 .VBComponents(x).CodeModule.DeleteLines 1, _ .VBComponents(x).CodeModule.CountOfLines Next x End With On Error GoTo 0 End Sub Mike "Jim" wrote: Is it possible to program saving the current workbook without the vba code ? Regards & TIA |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Removing code in 'This Workbook' | Excel Programming | |||
removing a toolbar with code | Excel Programming | |||
Removing Workbook_Open code | Excel Programming | |||
Removing all code from a Project | Excel Programming | |||
Removing VBA Code (programatically) | Excel Programming |