So I am using this code:
Sub insert()
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.AddFromString ("Private Sub Workbook_BeforeSave ()")
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.AddFromString ("Cancel = True")
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.AddFromString ("Application.ThisWorkbook.Saved = True")
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.AddFromString ("End Sub")
End Sub
And I am getting this result:
Cancel = True
Application.ThisWorkbook.Saved = True
End Sub
Private Sub Workbook_BeforeSave()
I can not get the private sub to print a the top of the list. I can change the order of all the other but this always goes to the bottom. And so it will not work.
Any idea why?
or a different way to do this?
-Eds
Sub insert()
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.AddFromString ("Private Sub Workbook_BeforeSave ()")
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.AddFromString ("Cancel = True")
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.AddFromString ("Application.ThisWorkbook.Saved = True")
ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule.AddFromString ("End Sub")
End Sub
And I am getting this result:
Cancel = True
Application.ThisWorkbook.Saved = True
End Sub
Private Sub Workbook_BeforeSave()
I can not get the private sub to print a the top of the list. I can change the order of all the other but this always goes to the bottom. And so it will not work.
Any idea why?
or a different way to do this?
-Eds