參考引用:Crystal Reports Dynamic Image
--
Option Explicit
Dim Report As CRAXDRT.Report
Dim CRapp As New CRAXDRT.Application
Private WithEvents oSection As CRAXDRT.Section
Dim pic1 As OLEObject
Dim i As Integer
Private Sub Form_Load()
'set the report
Set Report = CRapp.OpenReport(App.Path + "\report1.rpt")
'set the section object to the Details section of the report.
Set oSection = Report.Sections("D")
'Loop through the report objects and see if they are pictures
For i = 1 To oSection.ReportObjects.Count
'fully qualified croleobjects as craxdrt.crOleobject.. otherwise you will get the error - object variable not set
' if it is a CrOleObject then
If oSection.ReportObjects(i).Kind = CRAXDRT.crOLEObject Then
'Set the pic1 object to the Ole Report object
Set pic1 = oSection.ReportObjects(i)
End If
Next i
'view the report
CrystalActiveXReportViewer1.ReportSource = Report
CrystalActiveXReportViewer1.ViewReport
End Sub
'section format event:
'this event fires every time this section is generated by the report.
Private Sub oSection_format(ByVal pFormattingInfo As Object)
'load the image. this can be done dynamically if desired.
Set pic1.FormattedPicture = LoadPicture(App.Path + "\test.bmp")
End Sub
Private Sub Form_Resize()
CrystalActiveXReportViewer1.Top = 0
CrystalActiveXReportViewer1.Left = 0
CrystalActiveXReportViewer1.Height = ScaleHeight
CrystalActiveXReportViewer1.Width = ScaleWidth
End Sub
沒有留言:
張貼留言