Sub OutlineSection()
' Before running this example, open a text document.
Dim objSel As TextSelection = DTE.ActiveDocument.Selection
' Move to the beginning of the document so we can iterate over the
' whole thing.
objSel.StartOfDocument()
While objSel.FindPattern("Function ")
' If we found the beginning of a debug-only section, save the
' position.
Dim lStartLine As Long = objSel.TopPoint.Line + 1 ' Increment by one to show Function outside of outline
Dim lStartColumn As Long = objSel.TopPoint.LineCharOffset
' Look for the end.
If objSel.FindPattern("End Function") Then
' Select the entire section and outline it.
objSel.SwapAnchor()
objSel.MoveToLineAndOffset(lStartLine, lStartColumn, True)
objSel.OutlineSection()
objSel.LineDown()
End If
End While
objSel.StartOfDocument()
While objSel.FindPattern("Sub ")
' If we found the beginning of a debug-only section, save the
' position.
Dim lStartLine As Long = objSel.TopPoint.Line + 1 ' Increment by one to show Sub outside of outline
Dim lStartColumn As Long = objSel.TopPoint.LineCharOffset
' Look for the end.
If objSel.FindPattern("End Sub") Then
' Select the entire section and outline it.
objSel.SwapAnchor()
objSel.MoveToLineAndOffset(lStartLine, lStartColumn, True)
objSel.OutlineSection()
objSel.LineDown()
End If
End While
End Sub