Change Properties of Objects in A Crystal Report
Change Properties of Objects in A Crystal Report
htm
Search
Crystal Reports
Home Home > Knowledge Bank > Crystal Reports > Change Font of Field/Text objects in Crystal report with VB
About me
How do I change the Font of Field objects and Text objects in a Crystal report Programatically ? How do I let the user
Knowledge Bank
change the Font of Field objects and Text objects in a Crystal report using VB/RDC/CRAXDRT?
Guestbook
Photo Album
Contact Me
Introduction
The article shows you how to let the user change Font properties of the Field and Text objects in a Crystal report. The article demonstrates it
using the CRAXDRT object Library inconjection with the ShowFont Commondialog control and IFontDisp object.
Dim I As Integer
Dim X As Integer
1 of 3 10/11/2019, 5:16 AM
Change the Font of Field and Text objects in a Crystal report Programatically http://www.mahipalreddy.com/cr/article52445.htm
Full Code
'Add a command button and a Crystal Report Viewer Control and a Microsoft Common Dialog Control to you form
'Reference Crystal Reports 8/8.5/9/10 ActiveX Designer Run time Library
'Paste the following code into the form code window
'Change the path "C:\crtests\Report1.rpt" to suit yours
'Initialize the font object. Populate it with the Font of the Form
Set myFont = Me.Font
'now loop through all the sections and apply Font properties to field and text objects
For I = 1 To crxReport.Sections.Count
For X = 1 To crxReport.Sections(I).ReportObjects.Count
Set reportObject = crxReport.Sections(I).ReportObjects.Item(X)
If reportObject.Kind = crTextObject Or reportObject.Kind = crFieldObject Then
reportObject.Font.Name = myFont.Name
reportObject.Font.Bold = myFont.Bold
reportObject.Font.Italic = myFont.Italic
reportObject.Font.Size = myFont.Size
reportObject.Font.Underline = myFont.Underline
reportObject.Font.Strikethrough = myFont.Strikethrough
End If
Set reportObject = Nothing
Next X
Next I
2 of 3 10/11/2019, 5:16 AM
Change the Font of Field and Text objects in a Crystal report Programatically http://www.mahipalreddy.com/cr/article52445.htm
Top
www.mahipalreddy.com
Terms and Conditions of Use
Copyright © 2004 - 2006 Mahipal Padigela. All rights reserved.
3 of 3 10/11/2019, 5:16 AM