Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a workbook that has password protected VB code (it must stay password
protected). Below is my code, my issue is that I can't delete the VB code without entering the password but I have no clue how to do that. Any help is appreciated!!! Private Sub cmdMyButton4_Click() Call BreakLinks Application.Dialogs(xlDialogSaveAs).Show "TBD" Call DeleteVBA ActiveSheet.Shapes("cmdMyButton4").Delete End Sub Sub BreakLinks() Dim Links As Variant Dim i As Integer With ActiveWorkbook Links = .LinkSources(xlExcelLinks) If Not IsEmpty(Links) Then For i = 1 To UBound(Links) .BreakLink Links(i), xlLinkTypeExcelLinks Next i End If End With End Sub Sub DeleteVBA() Dim VBProj As VBIDE.VBProject Dim VBComp As VBIDE.VBComponent Dim CodeMod As VBIDE.CodeModule Set VBProj = ActiveWorkbook.VBProject For Each VBComp In VBProj.VBComponents If VBComp.Type = vbext_ct_Document Then Set CodeMod = VBComp.CodeModule With CodeMod .DeleteLines 1, .CountOfLines End With Else VBProj.VBComponents.Remove VBComp End If Next VBComp End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete code after use | Excel Programming | |||
Delete Code | Excel Programming | |||
Code to delete a Line in a another code | Excel Programming | |||
VBA code delete code but ask for password and unlock VBA protection | Excel Programming | |||
VBA code to delete VBA code in another Workbook | Excel Programming |