Insert copyright macro for VisualStudio

Here’s a useful macro for inserting copyrights into source code in Visual Studio.

    Sub Copyright()
        ' Insert copyright
        DTE.ActiveDocument.Selection.StartOfDocument()
        DTE.ActiveDocument.Selection.Text = "// (c) Brad Reimer.  All Rights Reserved."
        DTE.ActiveDocument.Selection.NewLine()

        ' Remove old copyright
        DTE.ActiveDocument.Selection.EndOfLine(True)
        If DTE.ActiveDocument.Selection.Text.StartsWith("// (c)") Then
            DTE.ActiveDocument.Selection.Delete(2)
        End If

        ' Insert newline before usings
        DTE.ActiveDocument.Selection.EndOfLine(True)
        If DTE.ActiveDocument.Selection.Text.StartsWith("using") Or DTE.ActiveDocument.Selection.Text.StartsWith("#include") Then
            DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
            DTE.ActiveDocument.Selection.NewLine()
        End If
    End Sub