|
-
May 27th, 2010, 05:22 PM
#1
Thread Starter
Lively Member
Strech image in crystal reports
I'm setting up the print layout for my program in Crystal Reports 9. I have 6 images that need to be of a fixed size on the page. I want the picture box to be set to the size and location. I want and the image loaded dynamicaly to scale to it. Isn't there just a switch somewhere to stretch image.
This is what i have now
Dim myPic As StdPicture
Dim mypath
mypath = Unit1Pic11.Value
Set myPic = LoadPicture("C:\Program Files\Denali" & mypath)
Set Picture1.FormattedPicture = myPic
-
May 28th, 2010, 09:10 AM
#2
Re: Strech image in crystal reports
Assuming Picture1 is a CRAXDRT.OLEObject control, use the XScaling and YScaling properties to scale the image. These properties correspond to the Scale Height and Width text boxes on the Format Editor screen within the Crystal IDE (right click the ole object and select the Format Graphic menu item. Then switch to the Picture tab).
-
May 28th, 2010, 12:37 PM
#3
Re: Strech image in crystal reports
-
Jun 4th, 2010, 04:20 AM
#4
Thread Starter
Lively Member
Re: Strech image in crystal reports
That changes the picture box size, it doesn't stretch the image to fit the box
-
Jun 4th, 2010, 04:42 AM
#5
Thread Starter
Lively Member
Re: Strech image in crystal reports
I'm sorry, it seems I am not explaining what I need correctly. I have a report I need to print that has two picture boxes. On start up it will load one of 20 different images in each of the two boxes. No mater what picture loads into the picture box I need it to scale to the size of the picture box I have preset. I hope someone can help me with this without pasting 20 lines of code from an existing program. I'm having problems picking out the lines I need. I have read dozens of posts on this and not seen anything that works. I beginning to think I am the only one in the world who ever needed to do this in CR.
-
Jun 4th, 2010, 09:14 AM
#6
Re: Strech image in crystal reports
I only have Crystal 8.5 and whenever I adjust the size of an ole object the original image is automatically stretched/skewed.
You said you didn't want code but the following is pretty basic.
The Form contains a Command Button and CRViewer controls.
The report contains an OLE Object in the Report Header section
The OLE Object was set with an image at design time.
The code changes the image and size of the ole object at runtime.
Code:
Option Explicit
Private crApp As CRAXDRT.Application
Private WithEvents sec As CRAXDRT.Section
Private pic As CRAXDRT.OLEObject
Private Sub Command1_Click()
Dim rep As CRAXDRT.Report
Set rep = crApp.OpenReport("C:\projects\report1.rpt")
Set sec = rep.Sections("RH")
Set pic = sec.ReportObjects(1)
pic.XScaling = 2
pic.YScaling = 0.5
CRViewer1.ReportSource = rep
CRViewer1.ViewReport
End Sub
Private Sub sec_format(ByVal pFormattingInfo As Object)
Set pic.FormattedPicture = LoadPicture("c:\test.jpg")
End Sub
Private Sub Form_Load()
Set crApp = New CRAXDRT.Application
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set crApp = Nothing
End Sub
-
Jun 4th, 2010, 11:46 AM
#7
Thread Starter
Lively Member
Re: Strech image in crystal reports
This looks simple but it's not working.
I have a CR page that already comes up and loads the images in the OLE picture box. It looks like all I have to do is
Dim myPic As StdPicture
Dim mypath
mypath = Unit1Pic11.Value
Set myPic = LoadPicture("C:\Program Files\Denali" & mypath)
Set Picture1.FormattedPicture = myPic
myPic.XScaling = 2
myPic.YScaling = 0.5
It says the object doesn't support this procedure. If I use the X and Y scaling in the object drop down it just re sizes the picture box. Do I need a default picture in the box before I load everything , because prior to loading the the image above there is nothing in it. I am also using CR 8.5.
-
Jun 4th, 2010, 01:57 PM
#8
Re: Strech image in crystal reports
Do I need a default picture in the box before I load everything
For me, the code works with or without specifying a picture in the report object.
It says the object doesn't support this procedure.
myPic is a StdPicture object. XScaling and YScaling are properties of the CRAXDRT.OLEObject.
For me, the XScaling and YScaling properties must be set before executing the report.
And the line Set Picture1.FormattedPicture = myPic
must be in the Section's Format event otherwise I get an "Permission Denied" error.
-
Jun 4th, 2010, 03:34 PM
#9
Thread Starter
Lively Member
Re: Strech image in crystal reports
Ok let me pay with it a while. Thank you for the help. I will let you know what happens.
-
Jun 4th, 2010, 04:17 PM
#10
Thread Starter
Lively Member
Re: Strech image in crystal reports
I can see where to declare the CRAXDRT.OLEObject. but i can't see where to put one in my form. There isn't one in the insert dropdown. Do I need to add it in componets, if so where do what is it called
-
Jun 4th, 2010, 05:47 PM
#11
Re: Strech image in crystal reports
???
You don't put a CRAXDRT.OLEObject on a VB Form, it is on the Report.
The code I posted simply opens the Crystal rpt file and gets a reference to the OLEObject that is in the ReportHeader section.
-
Jun 4th, 2010, 07:12 PM
#12
Thread Starter
Lively Member
Re: Strech image in crystal reports
When I choose to insert the OLE object into the CR form, I choose a BMP type this gives me the ICROle.Object. I don't see where I go to insert a CRAXDRT.OLEObject. That might be why the resizing isn't working. When I declare myPic as a CRAXDRT object it say the object is missing.
How do I change this "Dim myPic As CRAXDRT" so it will reference the existing picture box.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|