Hi All!
I am urgently in need of code to do the following:
I have an Excel file where the VBA Editor is locked from being viewed. A password is used. Assume it is "Harry".
At some point, the user has to make use of event driven code to input certain data in an InputBox.
If the data is correct, a line of code is to be deleted from a specific module. The code that I use looks like this:
Sub InputBoxSub()
Dim Message As String, Title As String, Default As String, MyValue As String
Message = "Please enter required password" ' Set prompt.
Title = "Changing Demo to Full Blown Version" ' Set title.
Default = "Please enter the supplied password here" ' Set default.
MyValue = InputBox(Message, Title, Default)
If MyValue = "{7ABF5F20-3DC6-11D7-9CDF-CA3FDD201372}" Then
Dim strCodeLine As String
Dim lngLine As Long
With Application.VBE.ActiveVBProject.VBComponents("Module25").CodeModule
If .Find("Call AktiveerDemo", 1, 1, 80, -1) Then
For lngLine = .ProcStartLine("Activate", vbext_pk_Proc) To .ProcCountLines("Activate", vbext_pk_Proc)
strCodeLines = .Lines(lngLine, 1)
If InStr(1, strCodeLines, "Call AktiveerDemo", vbTextCompare) > 0 Then
.DeleteLines lngLine, 1
Exit For
End If
Next
End If
End With
MsgBox "Your Demo version has now been changed to a fully workable file"
Else
MsgBox "Wrong Password!"
Exit Sub
End If
End Sub
Display More
When the password is supplied, everything worked fine UNTIL I locked the project from being viewed.
I now get an error saying that it cannot write to the VBA Editor because it is locked.
How can I unlock the project with the relevant password (Assume "Harry", as mentioned) so that the code may be deleted,
AND
then to lock it afterwards?
Your speedy assistance will, as always, be sincerely appreciated!
Kind regards
Harry