VBA Run-time error 4120 executing Application.ShowWindowsInTaskbar and Options.ReplaceSelection = True RRS feed

  • General discussion

  • A customer recently reported Run-time error 4120 to me when opening a document which contained the statement 'Application.ShowWindowsInTaskbar=True' in an AutoOpen procedure. I had seen something similar before, which was described by and could be cured by the actions in http://support.microsoft.com/kb/948682, (i.e. ensuring that the user's name and initials are set in Word Options). However, in this case the user's details were already set.

    Further investigation revealed the root cause of the problem was that the document was protected with a 16-character password. Protecting it with a shorter password removed the problem. I was pointed in the direction of this conclusion by http://social.msdn.microsoft.com/Forums/vstudio/en-US/0401ea56-5ca5-4bb8-aaeb-006fee8d13fa/word-password-maximum-key-length.  

    I also checked the impact of long passwords on some of the other commands (such as 'Options.ReplaceSelection = True') that were mentioned on the Web by people who have fallen foul of the 'Blank Username' problem. The ones I tested also produced a 4120. 

    I have put a document which can be used to illustrate this on my SkyDrive - see http://sdrv.ms/1ikSCsg. The password is aaaaaaaaaa123456 (10 a's then the digits).

    I hope that posting here will help others who might encounter the same error, though I suspect not many users will use such long passwords.

    It would also be good for Microsoft to take note and either fix the UI so that >15-character passwords are not allowed, or prevent the 4120 error when such passwords are present. It is mildly interesting to note that pre-2007 versions of Word (XP and 2003) were not afflicted by this error in my tests. 

    Sunday, November 17, 2013 10:40 AM

All replies

  • Hi,

    Thank you for sharing this useful point with us in the MSDN forum.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 18, 2013 7:15 AM