Are you asking how to trigger a macro when a workbook is opened? If so right click on the small Excel icon in the left hand top corner of your workbook (next to File). Choose View Code from the list. Set the left hand dropdown to Workbook and the right hand drop down to Open. Now writ your code. Hope this is what you want
You can set Password protection for your project by opening the VB editor and choosing Tools>VBA ProjectProperties>Protection. Don't lose your password