Is there a way to print all (*.cs) files in a solution at once, that is, without clicking on each of them and then hitting print?
From what I gather from a similar question asked elsewhere, this "feature" is not build into Visual Studio.
However it looks like MSDN has a macro you can use to print all of your code; perhaps you can use this, or something like it:
Sub PrintItemsInSelectedProject()
Dim proj As Project
Dim objProj As Object()
objProj = DTE.ActiveSolutionProjects
If objProj.Length = 0 Then
Exit Sub
End If
proj = DTE.ActiveSolutionProjects(0)
PrintItemsInSelectedProject(proj.ProjectItems)
End Sub
Private Sub PrintItemsInSelectedProject( _
ByVal projitems As ProjectItems)
Dim projitem As ProjectItem
For Each projitem In projitems
If (IsPrintableFile(projitem) = True) Then
If (projitem.IsOpen( _
EnvDTE.Constants.vsViewKindTextView)) Then
projitem.Document.PrintOut()
Else
Dim doc As Document
doc = projitem.Open( _
EnvDTE.Constants.vsViewKindTextView).Document
doc.PrintOut()
doc.Close(vsSaveChanges.vsSaveChangesNo)
End If
End If
PrintItemsInSelectedProject(projitem.ProjectItems)
Next
End Sub
Function IsPrintableFile( _
ByVal projItem As ProjectItem) As Boolean
Dim fileName As String
Dim extensions As _
New System.Collections.Specialized.StringCollection
' If you add a file to your project that is of
' a type that can be printed,
' then add the extension of that
' file type to this list.
Dim exts As String() = {".cs", ".vb", _
".aspx", ".xsd", ".xml", ".xslt", _
".config", ".htm", ".html", ".css", _
".js", ".vbs", ".wsf", ".txt", ".cpp", _
".c", ".h", ".idl", ".def", ".rgs", ".rc"}
extensions.AddRange(exts)
fileName = projItem.FileNames(1)
Return extensions.Contains( _
System.IO.Path.GetExtension(fileName).ToLower())
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With