title: visual studio 2008 macro: write to output pane
body: <p>In a Visual Studio macro, how do you write execution information on the output pane (i.e. the window that usually contains build output)?</p>
  
  <p>I'm using Visual Studio 2008, if that is relevant.</p>
  
  <p><strong>Solution</strong>: I added the following subs to my macro project, I'm posting them here in case they could be useful.</p>
  
  <pre><code>Private Sub Write(ByVal name As String, ByVal message As String)
      Dim output As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
      Dim window As OutputWindow = output.Object
      Dim pane As OutputWindowPane = window.OutputWindowPanes.Item(name)
      pane.Activate()
      pane.OutputString(message)
      pane.OutputString(Environment.NewLine)
  End Sub
  
  Private Sub Log(ByVal message As String, ByVal ParamArray args() As Object)
      Write("Debug", String.Format(message, args))
  End Sub
  
  Private Sub Log(ByVal message As String)
      Write("Debug", message)
  End Sub
  </code></pre>