VBA Password Question

D

Danny

Hi,

I found the Create Event Procedure macro below from Mr. Chip Pearson's
website that is very helpful to my project.

Dim StartLine As Long
With ActiveWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
StartLine = .CreateEventProc("Open", "Workbook") + 1
.InsertLines StartLine, _
"Msgbox ""Hello World"",vbOkOnly"
End With

However, the macro won't work if the VBA is protected.

Is there a way that the macro above be edited to unprotect the VBA (say
password is "ABCD"), then, the above macro will run, then, the VBA will be
protected with the same password?

Thank you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top