View Single Post
 
Old 07-24-2019, 09:03 PM
kiwimtnbkr kiwimtnbkr is offline Windows 10 Office 2010 64bit
Advanced Beginner
 
Join Date: Oct 2017
Posts: 69
kiwimtnbkr is on a distinguished road
Default

Resolved by deleting the macro when saving the file as a .xlsm file. The following code was placed inside a Module.

Code:
Sub DeleteWorksheet_Activate()
Dim VBComp As VBIDE.VBComponent
Dim VBComps As VBIDE.VBComponents
Dim VBProj As VBIDE.VBProject
Dim CodeMod As VBIDE.CodeModule
Dim StartLine As Long
Dim NumLines As Long
Dim ProcName As String

Set VBComps = This Workbook.VBProject.VBComponents
Set VBProj = ActiveWorkbook.VBProject
Set VBComp = VBProj.VBcomponent("Sheet4")
Set CodeMod = VBComp.CodeModule

For Each VBComp In VBComps
     Select Case VBComp.Type
          Case vbext_ct_MSForm
               VBComps.Remove VBComp
     End Select
Next VBComp

ProcName = "Worksheet_Activate"
     With CodeMod
          Startline = .ProcStartLine(ProcName, vbext_pk_Proc)
          Numline = .ProcCountLine(ProcName, vbext_pk_Proc)
          .DeleteLines StartLine:=StartLine, Count:=NumLines
     End With
End Sub
Reply With Quote