Originally Posted by johnske
Not sure if this's what you're after (it's a mod from a very-much WIP)
[vba]
Option Explicit
'
Sub GetProjectCodeForPrinting()
'
Dim N As Long
Dim Component As VBComponent
Dim OpenBook As Workbook
'
Set OpenBook = ActiveWorkbook
'
Application.ScreenUpdating = False
Workbooks.Add (xlWBATWorksheet)
'
GoSub FormatSheet
'
For Each Component In OpenBook.VBProject.VBComponents
With [A3]
.Value = " " & Component.Name & " Code Module"
With .Font
.Size = 9
.Bold = True
.Underline = True
.ColorIndex = 11
End With
End With
'
With Component.CodeModule
For N = 1 To .CountOfLines
If .Lines(N, 1) = Empty Then
Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = "'"
Else
'put space before and after codeline (this is needed)
Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = " " & .Lines(N, 1) & " "
End If
Next
End With
'Call FormatCodeAsPerVBIDE
'Call ConvertToBBcode
ActiveWorkbook.Sheets.Add after:=Sheets(Sheets.Count)
GoSub FormatSheet
Next
'
Application.DisplayAlerts = False
Sheets(Sheets.Count).Delete 'there's 1 too many sheets
Application.DisplayAlerts = True
Application.ScreenUpdating = True
'
Exit Sub
'
FormatSheet:
'
With ActiveWindow
.DisplayHeadings = False
.DisplayGridlines = False
End With
'
With ActiveSheet
With .Cells.Font
.Name = "Verdana"
.Size = 8
End With
'
With .[A1]
.Value = " " & OpenBook.Name & " " & OpenBook.VBProject.Name
With .Font
.Size = 12
.Bold = True
.Underline = True
End With
End With
End With
Return
'
End Sub
[/vba]