There may be a standard block of text, such as terms, that you’d like to always display with certain reports. This is possible by adding a small block of code to a custom report that looks for a specific .RTF file.
First, create the .RTF file with the information you’d like to display. Then, follow these steps: Click Start > Reports > Standard Report Designer.
1. Once the Report Designer is opened, Click File > New [If you are creating a new report]. If you are not creating a new report, click File > Open > Opening Existing Report. Skip to Step 5.
2. Choose Report Based on existing Report and Click Next.
3. Select the Report you want to use as a Template and Click Next.
4. Give the Report a name and click Finish.
5. Once the Report is opened, select a RichTextBox from the ToolBox on the left and drag it into the desired section.
6. On the Right, click on the Data Explorer tab and find the ProjectFolder data field. You will need to expand the nodes to find it.
7. Select and drag it into the same section as the RichTextBox.
8. With that ProjectFolder textbox selected, change the “Name” property on the bottom-right to “txtFolder” and set the “Visible” property to false.
9. Click on the Script tab at the bottom of the window.
10. At the top, click on the Object dropdown and select the section with your RichTextbox and TextBox in it.
11. Click on the Event dropdown and select Format. This will either create a section in the code or take you to the place in the script where that section exists.
12. Between the Sub and End Sub text paste the following code. You will need to replace the text in brackets with the proper data:
Dim folder As string = ReportUtilities.ReturnTextBoxValue(rpt, “[Section Name]”, “txtFolder”)
Dim fileName As string
dim file As string
fileName = “[Name of the file you want].rtf”
file = System.IO.Path.Combine(folder, fileName)
if System.IO.File.Exists(file) Then
me.[Name of RichTextBox].LoadFile(file)
13. Once you are done. Click File > Publish and test the report by adding the file to a project. The file will need to have the exact name of the file referenced in your code. The file can be added via the Add button found on the Files tab within the Project Explorer.