Hi, and welcome!
This looks like a JScript sample from this MSDN article. To use it, first you need to make sure your form template will be using JScript for programming. To set the programming language for you form, please visit this link for IP2003 and this link for IP2007.
Next, you need to add an onLoad event (or Loading event for IP2007) to your form. Check here for 2003 instructions; in 2007 you can go to Tools / Programming / On Load Event.
The code, when we add the variable declaration and put it into the event will look like this:
function XDocument::OnLoad(eventObj)
{
var objCommandBars = Application.ActiveWindow.CommandBars;
objCommandBars("Menu Bar").Enabled = false;
objCommandBars("Standard").Enabled = false;
objCommandBars("Formatting").Enabled = false;
}
A word of warning -- I had to make my form Full Trust for this to work. For more information on setting forms to Full Trust, please visit this link.