Results 1 to 4 of 4

Thread: crystal report image..

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2006
    Posts
    719

    crystal report image..

    CType(mRpt.Section3.ReportObjects("pic1"), Object).image = "C:\picture.png"

    i encounter this error:

    Public member 'image' on type "PictureObject' not found

    what code should i write?

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: crystal report image..


  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2006
    Posts
    719

    Re: crystal report image..

    hello, this code is use to change image of CR during run time;

    Code:
    Dim Appl As New CRAXDRT.Application 
    Dim Report As CRAXDRT.Report 
    Public Oparam As CRAXDRT.ParameterFieldDefinitions 
    Dim WithEvents CrSecPH As CRAXDRT.Section 
    Public Pic1 As CRAXDRT.OLEObject
    --Section 3 of my report has the oleobject which hold the picture.
    I have put in delays to allow the refresh.

    Code:
    Private Sub cmdPrint_Click() 
    Dim I As Integer 
    Dim ix As Long 
    Dim intRow As Integer 
    Dim fileSource As String 
    Dim fileDestination As String 
    Dim PicPath As String 
    Dim thePicture As Object 
    
    Set Report = Appl.OpenReport(App.Path & "\report1.rpt", 1) 
    Report.PrinterSetup Me.hWnd 
    Set Report = Nothing 
    For intRow = 1 To fgShow.Rows - 1 
    If fgShow.TextMatrix(intRow, 5) = -1 Then 
    'Set Image 
    Text1.Text = App.path & "\Photo\" & Text1.text 
    
    intChangePicture = 0 
    Call Delay(20000) 
    'Print Report 
    Set Report = Nothing 
    Set Report = Appl.OpenReport(App.Path & "\report1.rpt", 1) 
    Set Oparam = Nothing 
    Set Oparam = Report.ParameterFields 
    Oparam.Item(1).AddCurrentValue (Text1.Text) 
    With CRViewer1 
    .EnableProgressControl = True 
    .ReportSource = Report 
    .ViewReport 
    Set CrSecPH = Nothing 
    Set CrSecPH = Report.Sections(3) 
    For I = 1 To CrSecPH.ReportObjects.Count 
    If CrSecPH.ReportObjects(I).Kind = crOleObject Then 
    
    Set Pic1 = Nothing 
    Set Pic1 = CrSecPH.ReportObjects(I) 
    Do 
    'Width of the image is changed to force the event CrSecPH.format to fire 
    ix = Pic1.Width 
    Pic1.Width = 100 
    Pic1.Width = ix 
    Call Delay(100000) 
    .RefreshEx False 
    Call Delay(100000) 
    ' .ShowLastPage 
    ' .ShowFirstPage 
    Loop While intChangePicture = 0 
    If intChangePicture = 1 Then 
    .ViewReport 
    .Zoom 100 
    End If 
    Exit For 
    End If 
    Next I 
    If intChangePicture = 1 Then 
    ' .RefreshEx False 
    Call Delay(100000) 
    ' .PrintReport 
    Report.PrintOut False 
    Call Delay(100000) 
    End If 
    End With 
    End If 
    Next intRow 
    Set Pic2 = Nothing 
    Set CrSecPH = Nothing 
    Set Oparam = Nothing 
    Set Report = Nothing 
    
    End Sub
    Code:
    Private Sub CrSecPH_Format(ByVal pFormattingInfo As Object) 
    Dim I As Integer 
    Dim PicPath As String 
    If intChangePicture = 0 Then 
    PicPath = Text1.Text & ".JPG" 
    
    (PicPath) 
    On Error GoTo ErrorHandler 
    Set Pic1.FormattedPicture = LoadPicture(PicPath) 
    ' Set Pic1.FormattedPicture = LoadPicture(App.Path & "\setup.JPG") 
    intChangePicture = 1 
    End If 
    Exit Sub 
    ErrorHandler: 
    Select Case Err.Number 
    Case 53 
    'MsgBox "Photo Missing for " & UCase(Trim(Text1.Text)) & " from file.", vbCritical, "No Photo" 
    intChangePicture = 2 
    Case Else 
    MsgBox Err.Description, vbCritical, Err.Number 
    End Select 
    End Sub
    BUt unfortunately, im using crystal report of vs.net 2005? i cant find a way to use this code? kindly me pls?

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2006
    Posts
    719

    Re: crystal report image..

    I even try;

    Code:
    CType(mRpt.Section3.ReportObjects("pic1"), Object).Formattedimage = "C:\picture.png"
    but it still doesnt work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width