If you use a Vegas version older than 14, change "using ScriptPortal.Vegas" to "using Sony.Vegas" on line 13 in the script.
Locate your Vegas installation folder, commonly C:\Program Files\Vegas Pro {version}
Put the .cs file inside the Script Menu folder
If Vegas is already open, go to Tools -> Scripting -> Rescan Script Menu folder
Optional Add this script to your Vegas toolbar for faster access. Just go on Options -> Customize Toolbar; then, scroll down until you see the script name, and add it to your toolbar in the desired position.