Macro (SVB) Programs Example - Customizing Reports

The Report object includes various properties and methods to permit extensive customizations of fonts, colors, etc. Copying Cells from a Spreadsheet into a Report illustrates how to move information into the report window via the Clipboard. This simple example program demonstrates how text can be moved directly into the report and then formatted.

' This program illustrates how to modify text in report ' windows (objects) 
Sub main
Dim i As Long

' Create a new Report object
Set r=New Report

' Make the new Report visible
r.Visible=True

' "Set the cursor" by selecting the range of characters ' from the last character to the last character.
r.SetSelection(scLastCharacter, scLastCharacter) r.SelectionText = "Some text"

' Add carriage Return line feed.
r.SelectionText = vbCrLf

' "Remember" the current cursor position; note that ' the cursor position is referenced from 0.
' Function GetSelection(Start As Long, End As Long) will
' return the cursor position where the current text
' selection starts and ends; so variable i will "remember"
' the place following the vbCrLf.

r.GetSelection(i,i)

i=r.CharacterCount 
r.SelectionText = "More text on the next line"

' Change the font of this text
r.SetSelection(i,scLastCharacter) Set Font=r.SelectionFont Font.Bold=True Font.Italic=True

' Set another line of text
r.SetSelection(scLastCharacter, scLastCharacter)

' Add carriage Return line feed
r.SelectionText = vbCrLf r.SelectionText = "Third line of text"

' Select all text from line 3 to line 4 (i.e., select line 3)
r.SetSelection(r.LineNumberToCharacterPosition(3), _ r.LineNumberToCharacterPosition(4)) Set Font=r.SelectionFont

' Set color to Blue (see the QBColor function for details)
Font.Color=QBColor(1)

End Sub

Refer to General SVB Syntax Documentation for additional details on how to set colors and predefined string constants useful for handling custom text.