Thursday, April 28, 2011

"50289 Can't perform operation since the project is protected" but why?

I am supplying the correct password

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("H:\M\X\C.xls", 0, , , "password")

'any of these lines cause the error mentioned

Set vbcomp = objWorkbook.VBProject.VBComponents(modname)
objWorkbook.VBProject.VBComponents.Remove vbcomp
objWorkbook.VBProject.VBComponents.Import modpath & modtest

Any ideas what the problem might be? Tools-Macro-Security is set to allow VB project access

From stackoverflow
  • The VBA project itself is protected by a password which is different then the worksheet password. Open the VBA IDE - select Tools-VBA Project Properties and look at the Protection Tab.

    Not sure how or if you can remove the VBA Project password using code.

    adolf garlic : Correct. It does not appear to be possible to removed the password on the VBA project, unless you use a hideous 'sendkeys' type workaround.
  • This may sound extreme, however I managed to get around this by downloading Windows Installer Clean up Utility (look for msicuu2.exe in Google) and removed office 2003. I then reinstalled office 2003 and my problem had disappeared. Hope it solves your probelm too. Alex

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.