Visual Studio Macros
Find here some usefull macros to use in Microsoft Visual Studio IDEs
Visual Studio 6
Sub Copyright()
'DESCRIPTION: Output a copyrigth notice for your C++ file.
Dim fileIsHeaderFile
fileIsHeaderFile=False
ActiveDocument.Selection.StartOfDocument
'ActiveDocument.Selection.LineUp
ActiveDocument.Selection.NewLine
ActiveDocument.Selection.StartOfDocument
ActiveDocument.Selection = "// "
'ActiveDocument.Selection.CharRight
ActiveDocument.Selection = ActiveDocument.Name
ActiveDocument.Selection.CharLeft dsExtend
If (ActiveDocument.Selection = "h" or ActiveDocument.Selection = "H") Then
fileIsHeaderFile=True
End If
ActiveDocument.Selection.StartOfLine
ActiveDocument.Selection.EndOfLine dsExtend
ActiveDocument.Selection.ChangeCase dsUppercase
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//"
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "// Copyright (c) 2007 Stéphane Lenclud, All rights reserved."
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "//"
ActiveDocument.Selection.NewLine
if (fileIsHeaderFile) Then
FileGuard
End If
End Sub
Sub FileGuard()
'DESCRIPTION: Output a file guard for you C++ file.
Dim a
a = "__" & ActiveDocument.Name & "__"
'ActiveDocument.Selection.StartOfDocument
ActiveDocument.Selection.NewLine
'ActiveDocument.Selection.LineUp
ActiveDocument.Selection = "#ifndef "
ActiveDocument.Selection = a
ActiveDocument.Selection.CharLeft
ActiveDocument.Selection.CharLeft
ActiveDocument.Selection.CharLeft dsExtend
Do While (ActiveDocument.Selection<>"." and ActiveDocument.Selection<>"_" )
ActiveDocument.Selection.CharLeft
ActiveDocument.Selection.CharLeft dsExtend
Loop
ActiveDocument.Selection="_"
ActiveDocument.Selection.StartOfLine
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.EndOfLine dsExtend
ActiveDocument.Selection.ChangeCase dsUppercase
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "#define "
ActiveDocument.Selection = a
ActiveDocument.Selection.CharLeft
ActiveDocument.Selection.CharLeft
ActiveDocument.Selection.CharLeft dsExtend
Do While (ActiveDocument.Selection<>"." and ActiveDocument.Selection<>"_" )
ActiveDocument.Selection.CharLeft
ActiveDocument.Selection.CharLeft dsExtend
Loop
ActiveDocument.Selection="_"
ActiveDocument.Selection.StartOfLine
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.EndOfLine dsExtend
ActiveDocument.Selection.ChangeCase dsUppercase
ActiveDocument.Selection.CharRight
ActiveDocument.Selection.EndOfDocument
ActiveDocument.Selection.NewLine
ActiveDocument.Selection = "#endif"
End Sub
Visual Studio 8
Sub Copyright()
'DESCRIPTION: Output a copyrigth notice for your C++ file.
Dim fileIsHeaderFile
fileIsHeaderFile = False
ActiveDocument.Selection.StartOfDocument()
ActiveDocument.Selection.NewLine()
ActiveDocument.Selection.StartOfDocument()
ActiveDocument.Selection.Text = "// "
ActiveDocument.Selection.Text = ActiveDocument.Name
'ActiveDocument.Selection.CharLeft(dsExtend)
'ActiveDocument.Selection.CharLeft(dsExtend)
ActiveDocument.Selection.CharLeft(True, 1)
If (ActiveDocument.Selection.Text = "h" Or ActiveDocument.Selection.Text = "H") Then
fileIsHeaderFile = True
End If
ActiveDocument.Selection.StartOfLine()
'ActiveDocument.Selection.EndOfLine(dsExtend)
'ActiveDocument.Selection.ChangeCase(dsUppercase)
ActiveDocument.Selection.EndOfLine(True)
ActiveDocument.Selection.ChangeCase(vsCaseOptions.vsCaseOptionsUppercase)
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.NewLine()
ActiveDocument.Selection.Text = "//"
ActiveDocument.Selection.NewLine()
ActiveDocument.Selection.Text = "// Copyright (c) 2007 Stéphane Lenclud, All rights reserved."
ActiveDocument.Selection.NewLine()
ActiveDocument.Selection.Text = "//"
ActiveDocument.Selection.NewLine()
If (fileIsHeaderFile) Then
FileGuard()
End If
End Sub
Sub FileGuard()
'DESCRIPTION: Output a file guard for you C++ file.
Dim a
a = "__" & ActiveDocument.Name & "__"
ActiveDocument.Selection.NewLine()
ActiveDocument.Selection.Text = "#ifndef "
ActiveDocument.Selection.Text = a
ActiveDocument.Selection.CharLeft()
ActiveDocument.Selection.CharLeft()
'ActiveDocument.Selection.CharLeft(dsExtend)
ActiveDocument.Selection.CharLeft(True, 1)
Do While (ActiveDocument.Selection.Text <> "." And ActiveDocument.Selection.Text <> "_")
ActiveDocument.Selection.CharLeft()
'ActiveDocument.Selection.CharLeft(dsExtend)
ActiveDocument.Selection.CharLeft(True, 1)
Loop
ActiveDocument.Selection.Text = "_"
ActiveDocument.Selection.StartOfLine()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
'ActiveDocument.Selection.EndOfLine(dsExtend)
DTE.ActiveDocument.Selection.EndOfLine(True)
'ActiveDocument.Selection.ChangeCase(dsUppercase)
DTE.ActiveDocument.Selection.ChangeCase(vsCaseOptions.vsCaseOptionsUppercase)
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.NewLine()
ActiveDocument.Selection.Text = "#define "
ActiveDocument.Selection.Text = a
ActiveDocument.Selection.CharLeft()
ActiveDocument.Selection.CharLeft()
'ActiveDocument.Selection.CharLeft(dsExtend)
DTE.ActiveDocument.Selection.CharLeft(True, 1)
Do While (ActiveDocument.Selection.Text <> "." And ActiveDocument.Selection.Text <> "_")
ActiveDocument.Selection.CharLeft()
'ActiveDocument.Selection.CharLeft(dsExtend)
DTE.ActiveDocument.Selection.CharLeft(True, 1)
Loop
ActiveDocument.Selection.Text = "_"
ActiveDocument.Selection.StartOfLine()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.CharRight()
'ActiveDocument.Selection.EndOfLine(dsExtend)
DTE.ActiveDocument.Selection.EndOfLine(True)
'ActiveDocument.Selection.ChangeCase(dsUppercase)
DTE.ActiveDocument.Selection.ChangeCase(vsCaseOptions.vsCaseOptionsUppercase)
ActiveDocument.Selection.CharRight()
ActiveDocument.Selection.EndOfDocument()
ActiveDocument.Selection.NewLine()
ActiveDocument.Selection.Text = "#endif"
End Sub