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

Thread: delete a macro with a macro ......password

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    164
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I was reading with interest about deleting a macro with a macro from a previouse question. My Macros are protected in VB so no one can veiw / alter them. I have tried to delete / alter a macro using this method, but I cant as it stops as the macro's are locked ...... Can this be done ??

    Thanks Guys.
    Mark.

  2. #2
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-18 00:11, mnmhenry wrote:
    I was reading with interest about deleting a macro with a macro from a previouse question. My Macros are protected in VB so no one can veiw / alter them. I have tried to delete / alter a macro using this method, but I cant as it stops as the macro's are locked ...... Can this be done ??


    Here is one way to do this provided you
    know the password



    Sub UnprotectVBProject()
    Dim wbproj As Object

    On Error Resume Next
    Set wbproj = ActiveWorkbook.VBProject
    Application.SendKeys "test", True
    Application.SendKeys "~", True
    wbproj.VBE.SelectedVBComponent.Activate
    On Error GoTo 0

    End Sub


    Here is another one I posted some years ago


    Option Explicit

    Const BreakIt As String = "%{F11}%TE+{TAB}{RIGHT}%V{+}{TAB}"

    Sub Change_VBA_PW()
    Dim WB As Workbook
    Dim Password As String

    Set WB = ActiveWorkbook
    Password = "ivan"
    Call SetVBProjectPassword(WB, Password)

    End Sub

    Sub SetVBProjectPassword(WB As Workbook, ByVal Password As String)
    'Needs reference to Visual Basic for Applications Extensibility Library
    Dim VBP As VBProject
    Dim OpenWin As VBIDE.Window
    Dim i As Integer

    Set VBP = WB.VBProject

    Application.ScreenUpdating = False

    ' close any code windows to ensure we are in the right project
    For Each OpenWin In VBP.VBE.Windows
    If InStr(OpenWin.Caption, "(") > 0 Then OpenWin.Close
    Next OpenWin

    WB.Activate

    SendKeys BreakIt & Password & "{tab}" & Password & "~" & "%{F11}~", True
    'SendKeys "enter", True
    WB.Activate
    SendKeys "%{F11}", True
    Application.ScreenUpdating = True
    End Sub




    Thanks Guys.
    Mark.
    Kind Regards,
    Ivan F Moala From the City of Sails

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
  •