Sub openWBEventsDisable_deleteCode()
Dim wb As Workbook, wbFullName As String
wbFullName = "workbook to be open full name" 'use here the workbook to be open full name
Application.EnableEvents = False 'this does not allow the Open event to be triggered
Set wb = Workbooks.Open(wbFullName)
Application.EnableEvents = True
Dim VBCompTarget As Object
Set VBCompTarget = wb.VBProject.VBComponents("ThisWorkbook")
With VBCompTarget.CodeModule
.DeleteLines 1, .CountOfLines 'delete existing code, if any
End With
'do whatever you usually do...
End Sub
1条答案
按热度按时间aor9mmx11#
请尝试下一种方法: