I have since found the answer. Go to (in VBA) Tools, VBAProject Properties,
Protection, click 'Lock for viewing' and enter a password. What I was missing
was that I was trying to activate the protection while I was working on the
file. When I opened the file this morning, I found protection had been
activated and I was not able to access my code without the password I had
entered. It obviously needs the file to be closed for protection to be
activated. Thanks for the reply.