Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 08-30-2023, 05:09 PM
Logit Logit is offline Is it possible to use a vba macro to delete other macros? Windows 10 Is it possible to use a vba macro to delete other macros? Office 2007
Expert
 
Join Date: Jan 2017
Posts: 591
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Code:
Option Explicit

'Reference : "Microsoft Visual Basic For Applications Extensibility"

Sub RemoveSheetModule()
    Dim wb     As Workbook
    Dim md     As Module
    Dim str    As String
   
    Application.ScreenUpdating = False
        Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & "URL Check - Copy.xlsm")
       
        For Each md In wb
            Select Case md.Name
                Case "Module1"
                    str = md.CodeName
                    With wb.VBProject.VBComponents(str).CodeModule
                        .DeleteLines 1, .CountOfLines
                    End With
                Case Else
            End Select
        Next md
       
        wb.Close True
    Application.ScreenUpdating = True
   
    MsgBox "Done...", 64
End Sub

Sub delModMacro()
Dim wb As Workbook
 Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & "CommandButton.xlsm")
    With wb.VBProject.VBComponents("Module1").CodeModule   '<--- change to ThisWorkbook for that module

            .DeleteLines 1, .CountOfLines

    End With
    
 MsgBox "Done...", 64
End Sub
Reply With Quote
 

Tags
delete module, macro help

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to use a vba macro to delete other macros? A few macros or functions run in a single macro? pentagram_31 Word VBA 15 10-29-2018 01:46 PM
Is it possible to use a vba macro to delete other macros? Compatibility of 2 macros in mail merge: Delete table rows + save individual PDFs Btop Word VBA 26 03-07-2018 01:45 PM
URGENT: Macro to open document and apply other macros successively Krategy Word VBA 1 12-02-2016 04:41 PM
VBA Powerpoint Macros: Set String in one Macro, use it in another Martijn6134 PowerPoint 0 11-09-2016 05:36 AM
Macro to find a word in first row of table and then perform two macros hmsrose Word VBA 5 01-30-2015 12:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft