|
-
August 20th, 2004, 12:12 PM
#1
printer selection using crviewer
Regarding the CRViewer9 component in VB6, is
there any way to ask the user which printer
they wish to use?

I get the report loaded up just fine, but
upon clicking the print button the windows
default printer is automatically selected.
Any suggestions?
-
August 20th, 2004, 12:24 PM
#2
Crystal Reports doesn't provide you with the option of choosing a printer. I ended up creating a separate form that asks the user for all the printer info and then it passes it to Crystal, bypassing Crystal's Print screen.
Code:
Dim prt As Printer
'This code would probably go in the Form_Load of your printer selection form
'Load Printers
For Each prt In Printers
cboSelectPrinter.AddItem prt.DeviceName
Next
'This code would go in the function that gets called
' when you click Print or OK in the Printer selection form
For Each prt In Printers
If prt.DeviceName = cboSelectPrinter.Text Then
Set Printer = prt
strDeviceName = prt.DeviceName
strDriverName = prt.DriverName
strPort = prt.Port
lngFromPage = Val(txtPageFrom.Text)
lngToPage = Val(txtPageTo.Text)
lngCopies = Val(txtCopies.Text)
Exit For
End If
Next
Set prt = Nothing
'This code goes after you set up your report
Report.SelectPrinter strDriverName, strDeviceName, strPort
Report.PrintOut False, intCopies, , intFromPage, intToPage
I'd rather be wakeboarding...
-
August 20th, 2004, 12:32 PM
#3
I think Report object will do the work (in Crystal 9)
Dim Appl As New CRAXDRT.Application
Dim Report As New CRAXDRT.Report
Set Report = Appl.OpenReport("Path")
Report.PrinterName = printername 'This will assign the printer name
Hope this will work
-
August 20th, 2004, 01:07 PM
#4
 Originally Posted by harmonycitra
Report.PrinterName = printername
"Compile Error: Can't assign read-only property"
This occurs when printername is Dim'd as a String or a Printer.
I'm giving malleyo's advice a go...
Last edited by epswing; August 20th, 2004 at 01:09 PM.
-
August 20th, 2004, 05:19 PM
#5
Sorry for that.
I should have checked before posting.
-
August 23rd, 2004, 08:42 AM
#6
malleyo, question about your posted code...
you have...
Code:
lngFromPage = Val(txtPageFrom.Text)
lngToPage = Val(txtPageTo.Text)
lngCopies = Val(txtCopies.Text)
...and then...
Code:
Report.PrintOut False, intCopies, , intFromPage, intToPage
Where did intCopies, intFromPage and intToPage come from? When debugging mid-execution, VB tells me that those three variables are Empty. If I change those three to lngCopies, lngFromPage and lngToPage it gives me a type mismatch on the Report.PrintOut line.
Any Ideas?
Edit: Oh wow, VB6 crashed, found this error log:
Code:
Line 19: Class CRVIEWER9LibCtl.CRViewer9 of control CRViewer1 was not a loaded control class.
Line 25: The property name lastProp in CRViewer1 is invalid.
Line 26: The property name _cx in CRViewer1 is invalid.
Line 27: The property name _cy in CRViewer1 is invalid.
Line 28: The property name DisplayGroupTree in CRViewer1 is invalid.
Line 29: The property name DisplayToolbar in CRViewer1 is invalid.
Line 30: The property name EnableGroupTree in CRViewer1 is invalid.
Line 31: The property name EnableNavigationControls in CRViewer1 is invalid.
Line 32: The property name EnableStopButton in CRViewer1 is invalid.
Line 33: The property name EnablePrintButton in CRViewer1 is invalid.
Line 34: The property name EnableZoomControl in CRViewer1 is invalid.
Line 35: The property name EnableCloseButton in CRViewer1 is invalid.
Line 36: The property name EnableProgressControl in CRViewer1 is invalid.
Line 37: The property name EnableSearchControl in CRViewer1 is invalid.
Line 38: The property name EnableRefreshButton in CRViewer1 is invalid.
Line 39: The property name EnableDrillDown in CRViewer1 is invalid.
Line 40: The property name EnableAnimationControl in CRViewer1 is invalid.
Line 41: The property name EnableSelectExpertButton in CRViewer1 is invalid.
Line 42: The property name EnableToolbar in CRViewer1 is invalid.
Line 43: The property name DisplayBorder in CRViewer1 is invalid.
Line 44: The property name DisplayTabs in CRViewer1 is invalid.
Line 45: The property name DisplayBackgroundEdge in CRViewer1 is invalid.
Line 46: The property name SelectionFormula in CRViewer1 is invalid.
Line 47: The property name EnablePopupMenu in CRViewer1 is invalid.
Line 48: The property name EnableExportButton in CRViewer1 is invalid.
Line 49: The property name EnableSearchExpertButton in CRViewer1 is invalid.
Line 50: The property name EnableHelpButton in CRViewer1 is invalid.
Line 51: The property name LaunchHTTPHyperlinksInNewBrowser in CRViewer1 is invalid.
Line 81: Property Picture in imgMPAQ had an invalid file reference.
-
August 23rd, 2004, 09:04 AM
#7
Oops...
My code was set up using a User-defined Type for the FromPage, ToPage, and Copies, when I copied the code to the forum, I just changed them into normal variables. I didn't realize that PrintOut requires an Integer and not a Long. Sorry about that.
Should be:
Code:
intFromPage = CInt(txtPageFrom.Text)
intToPage = CInt(txtPageTo.Text)
intCopies = CInt(txtCopies.Text)
Report.PrintOut False, intCopies, , intFromPage, intToPage
In regards to the VB6 crash, did you make sure that CRViewer was checked in your Components list?
I'd rather be wakeboarding...
-
August 23rd, 2004, 09:05 AM
#8
Edit: Oops, you posted while I was typing. I'll give that a try, thanks.
Edit2: If CRViewer wasn't checked as a component, wouldn't I not be able to add the control to the form?
Last edited by epswing; August 23rd, 2004 at 09:08 AM.
-
August 23rd, 2004, 09:14 AM
#9
Finally got everything working really well. Thanks a lot malleyo and harmonycitra for giving me a hand.
Here's what worked:
Code:
Private Sub CRViewer1_PrintButtonClicked(UseDefault As Boolean)
Dim cOrientation As CRPaperOrientation
Dim cSize As CRPaperSize
cOrientation = report.PaperOrientation
cSize = report.PaperSize
Dim p As Printer
For Each p In Printers
If p.DeviceName = cmbPrinters.Text Then
report.SelectPrinter p.DriverName, p.DeviceName, p.Port
Exit For
End If
Next p
report.PaperOrientation = cOrientation
report.PaperSize = cSize
Call SetLastUsedPrinter
End Sub
Last edited by epswing; August 23rd, 2004 at 01:14 PM.
-
August 24th, 2004, 10:35 PM
#10
Re: printer selection using crviewer
Guys what if you use Printersetup command before you print it with print button or with printout command :
try this :
http://www.xsorbit3.com/users/softwa...379441&start=0
-
August 30th, 2004, 01:10 PM
#11
Re: printer selection using crviewer
As stated above try:
CRReport.PrinterSetup 0
This forces the Printer Selection box to appear. This can be placed before the the Report.Printout and in the CRViewer place it in the Printer_Button click event.
Dean
-
August 31st, 2004, 08:43 AM
#12
Re: printer selection using crviewer
 Originally Posted by Dean_Reedy
As stated above try:
CRReport.PrinterSetup 0
This forces the Printer Selection box to appear. This can be placed before the the Report.Printout and in the CRViewer place it in the Printer_Button click event.
Dean
I spent several hours of my precious worktime looking for a solution such as this! I ended up having to code a form that would allow the user to choose a printer. And here it was so simple! Two lines of code! THANK YOU Dean!!
I'd rather be wakeboarding...
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
|