Unprotect VBAProjects using VBA

  • Thread starter Thread starter Marcus[Sweden]
  • Start date Start date
M

Marcus[Sweden]

I have a few different Excel-documents that I want to update
automatically trough another Excel-document. They all have the
VBAProjects protected and I need to replace several modules in each one
of them. How do I unlock them, I have the correct password.

I have read another thread but I can not make it work.
http://www.excelforum.com/t120946-s

Do anyone know have to make it work?

Thanks.

/Marcus
 
Sub UnPrtct()
UnprotectVBProject Workbooks("UnProtectProject.xls"), "123"
End Sub

Sub UnprotectVBProject(wb As Workbook, Pwd As String)
Set Application.VBE.ActiveVBProject = wb.VBProject
SendKeys "~" & Pwd & "~"
'keep the leading and trailing ~ characters -- these represent the ENTER
key
End Sub
 
I cant get this to work. The code should be in the dokument you are
updating from, or? I'm running XP, could that be any problem?

Thanks.

/Marcus
 
Back
Top