delete a macro with a macro ......password

mnmhenry

Board Regular
Joined
Mar 28, 2002
Messages
169
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.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
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


<pre/>
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
</pre>

Here is another one I posted some years ago

</pre>
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

</pre>


Thanks Guys.
Mark.
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,913
Members
448,532
Latest member
9Kimo3

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