Need help deleting 'ghost' macro
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Need help deleting 'ghost' macro

  1. #1


    Thought I would try to learn to create/use macros - don't know what I did but apparantly I created something... went to delete it (toolsmacrosselected 'this workbook' and deleted) - but the beast still lives on - when opening workbook I get warning msg. about file contains macros ( disable/enable?)- but when I go to toolsmacrosetc. - no macros are displayed - how do I get rid of this? Thanking in advance - the users of the workbook freak when they see the warning message containg both the 'macro' and 'virus' words...

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Sydney, Australia
    Post Thanks / Like
    1 Post(s)
    0 Thread(s)


    Put this code in another workbook, then select the workbook containing 'ghost' macros and run the macro DeleteAllVBA. This code is from Chip Pearson's website. YOU MUST set a reference to the Microsoft Visual Basic for Applications Extensibility library before running (Tools, References and then check that library) otherwise you'll get an error.


    Sub DeleteAllVBA()
    Dim VBComp As VBIDE.VBComponent
    Dim VBComps As VBIDE.VBComponents
    Set VBComps = ActiveWorkbook.VBProject.VBComponents
    For Each VBComp In VBComps
       Select Case VBComp.Type
          Case vbext_ct_StdModule, vbext_ct_MSForm, _
             VBComps.Remove VBComp
          Case Else
             With VBComp.CodeModule
                .DeleteLines 1, .CountOfLines
             End With
       End Select
    Next VBComp
    End Sub

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts