Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Need help deleting 'ghost' macro

  1. #1
    Guest

    Default

    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
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

    http://www.cpearson.com/excel/vbe.htm

    HTH,
    D

    Code:
    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, _
                vbext_ct_ClassModule
             VBComps.Remove VBComp
          Case Else
             With VBComp.CodeModule
                .DeleteLines 1, .CountOfLines
             End With
       End Select
    Next VBComp
    
    End Sub

Some videos you may like

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
  •