Report.SelectionRTF
Returns/sets the selected (rich-text formatted) text within the report.
Remarks: Documentation for RTF (Rich Text Format) is available online.
SVB Example
Adding formatted headers to a report:
Option Explicit
Option Base 1
Sub Main
Dim newanalysis As Analysis
Set newanalysis = Analysis (scBasicStatistics, Application.Open(Application.Path & "\Examples\Datasets\Cat Clinic.sta"))
With newanalysis.Dialog
.Statistics = scBasDescriptives
End With
newanalysis.OutputOption.ReportPlacement = scAnalysisReport
newanalysis.OutputOption.SupplementaryInfoLevel = scInfoLevelNone
newanalysis.Run
With newanalysis.Dialog
.Variables = "3 6 9"
.PairwiseDeletionOfMD = True
.DisplayLongVariableNames = False
.ExtendedPrecisionCalculations = False
.PlotMedianQuartileRange = False
.PlotMeanSEAndSD = False
.PlotMeanSD196TimesSD = True
.PlotMeanSE196TimesSE = False
.UserDefinedPercentiles = False
.ValidN = True
.Mean = True
.Median = False
.Mode = False
.GeometricMean = False
.HarmonicMean = False
.ConfLimitsForMeans = False
.Sum = False
.StandardDeviation = True
.Variance = False
.StandardErrorOfMean = False
.MinimumMaximum = True
.LowerUpperQuartiles = False
.Range = False
.QuartileRange = False
.Skewness = False
.Kurtosis = False
.StandardErrorOfSkewness = False
.StandardErrorOfKurtosis = False
.UseNumberOfIntervals = True
.NumberOfIntervals = 10
.NormalExpectedFrequencies = False
.KSAndLillieforsTestForNormality = True
.ShapiroWilkWTest = False
.ConfidenceIntervalForMeansPlot = 95
.CompressedStemAndLeaf = False
End With
Dim rpt As Report
newanalysis.RouteOutput(newanalysis.Dialog.Summary).Visible = True
Set rpt = newanalysis.RouteOutput(newanalysis.Dialog.Histograms).Report
Const REPORT_HEADER As String = _
"Weight Analysis for 1998-2000"
Const HISTOGRAM1_HEADER As String = _
"Weight Histogram (1998)"
Const HISTOGRAM2_HEADER As String = _
"Weight Histogram (1999)"
Const HISTOGRAM3_HEADER As String = _
"Weight Histogram (2000)"
'set the selection of the report to the beginning
of the document and then add our header to it
rpt.SetSelection(1,1)
rpt.SelectionText = REPORT_HEADER & vbCrLf
'Next, we will insert some text above the first graph.
'To do this, we will step over the embedded spreadsheet
'and the text that we just inserted and set the selection
'to be right above the graph. Call SetSelection again with
'the length of the text that we just inserted (including the carriage return after it).
'We must also add another 2 to that so that we can step over the
'embedded spreadsheet and the carriage return after it.
'Add these lines of code to move the selection above the first graph and to add a title above it
Dim TotalSizeOfInsertedText As Long
TotalSizeOfInsertedText = Len(REPORT_HEADER & vbCrLf)
rpt.SetSelection(TotalSizeOfInsertedText+2, _
TotalSizeOfInsertedText+2)
rpt.SelectionText = vbCrLf & HISTOGRAM1_HEADER
'Repeat this for the other graphs
TotalSizeOfInsertedText = TotalSizeOfInsertedText + _
Len(HISTOGRAM1_HEADER & vbCrLf)
rpt.SetSelection(TotalSizeOfInsertedText+4, _
TotalSizeOfInsertedText+4)
rpt.SelectionText = vbCrLf & HISTOGRAM2_HEADER
TotalSizeOfInsertedText = TotalSizeOfInsertedText + _
Len(HISTOGRAM2_HEADER & vbCrLf)
rpt.SetSelection(TotalSizeOfInsertedText+6, _
TotalSizeOfInsertedText+6)
rpt.SelectionText = vbCrLf & HISTOGRAM3_HEADER
rpt.SetSelection(1,1)
'add some space at the top of the report for our title
rpt.SelectionText = vbCrLf & vbCrLf
rpt.SetSelection(1,1)
'Add a formatted header to the report
rpt.SelectionRTF = _
"{\rtf1\ansi\ansicpg1252\deff0\deflang1029" & _
"{\fonttbl{\f0\fnil\fprq4\fcharset0 Arial;}}" & _
"{\colortbl ;\red0\green64\blue64;}" & _
"\uc1\pard\cf1\lang1033\ul\b\f0\fs22 " & _
"Weight Report (" & Trim(Str(Date)) & ")}"
End Sub
Copyright © 2020. Cloud Software Group, Inc. All Rights Reserved.
