Remove VBA code used in template

cm3pyro

New Member
Joined
Jul 12, 2010
Messages
5
I am working on a template that when the information is entered and the user clicks the SaveAs button the SaveAs dialog window directs them to the correct directory and inserts a SaveAs file named based on the value of a cell in the work book.

All of this works great. My problem is, if I need to edit a workbook I made using this template Excel will not let me save the file.

Is there a way to delete the VBA code used for the template so it does not transfer over into my .xls document?

thanks
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Here is the basic code to delete Code modules. You can incorporate it ito your code. When we save a workbook the new becomes the active one.
Code:
'===============================================================
'- DELETE STANDARD & CLASS MODULES FROM A WORKBOOK
'- Checks each one. Message box option to delete or keep
'- Brian Baulsom August 2007
'===============================================================
Sub REMOVE_CODEMODULES()
    Dim MyModule As Object
    '----------------------------------------------------------
    With ActiveWorkbook.VBProject
    For Each MyModule In .vbComponents
        Select Case MyModule.Type
            Case 1, 2 ' standard or class module
                SheetType = "Standard or Class Module"
                SheetName = MyModule.Name
                '---------------------------------------------
                '-
                MsgReply = MsgBox("Remove Code module : " _
                    & SheetName & " ?", vbYesNoCancel)
                If MsgReply = vbCancel Then Exit Sub
                If MsgReply = vbYes Then
                    .vbComponents.Remove MyModule
                End If
                '---------------------------------------------
        End Select
    Next
    End With
End Sub
'==============================================================
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,605
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top