Can the Visual Studio (debug) Output window be programmatically cleared?

For VS 2010 :

//Add reference EnvDTE100
static void ClearOutput()
{
    EnvDTE80.DTE2 ide = (EnvDTE80.DTE2)Marshal.GetActiveObject("VisualStudio.DTE.10.0");
    ide.ToolWindows.OutputWindow.ActivePane.Clear();
}

For VS 2008 try this code

EnvDTE80.DTE2 ide = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.9.0");
ide.ExecuteCommand("Edit.ClearOutputWindow", "");
System.Runtime.InteropServices.Marshal.ReleaseComObject(ide);

"VisualStudio.DTE.9.0" will change from VS version to version.