I have googled this and found multiple solutions for this but none of them have worked for me. I am inclined to believe this is because of my limited knowledge and ability w
Well, this code will delete the event. You save a copy of your workbook, so my idea is
Anyways, test it first several times to make sure it works. Altering VBA code with VBA itself can produce weird things somethimes.
Hope this helps.
All credits go to OZGRIZ
Also, make sure you check in Excel Options->Trusted Sites->Settings of Trusted Sites-> Macros Setting-> Check Trust access to Visual Basic Editor
Sub DeleteWorkbookEventCode()
''Needs Reference Set To _
'"Microsoft Visual Basic For Applications Extensibility"
'Tools>References.
'Also, make sure you check in Excel Options->Trusted Sites->Settings of Trusted Sites-> Macros Setting-> Check Trust access to Visual Basic Editor
Dim i As Integer
Dim MyStart, MyEnd As Integer
With ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
MyStart = 0
For i = 1 To .CountOfLines Step 1
If .Lines(i, 1) = "Private Sub Workbook_Open()" Then MyStart = i
If .Lines(i, 1) = "End Sub" And MyStart > 0 Then
MyEnd = i
Exit For
End If
Next i
.DeleteLines MyStart, (MyEnd - MyStart) + 1
End With
End Sub