Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Crystal Reports Won't Accept Change To Default Printer


(VB6, Crystal 9)

I've added all the printers on the computer to a combobox, so the user can select a printer to print from.

I'm using a method i found on this forum, to change the default printer - it stores the default printer, sets the newly selected printer as the default, then re-instates the old default printer. ( I could paste this code, but its a bit lengthy - its the class thats a modification of MSDN's article Q167735).

So i have a custom print dialog, and under the print button i have (where setprinter is the lengthy class):

Dim SetPrinter As New clsSetDefaultPrinter
Dim DeviceName As String
Dim smsg As String

DeviceName = cboPrinter.Text
If SetPrinter.SetPrinterAsDefault(DeviceName) Then
smsg = DeviceName & " -set"
Else
smsg = DeviceName & " -not set "
End If

MsgBox smsg, vbDefaultButton1, ""

MsgBox Printer.DeviceName & vbCrLf & Printer.DriverName & vbCrLf & _
Printer.Port, vbDefaultButton1, ""

MyReport.PrintOut False, 1, False

'destroy instance of printer class to restore printer to default
Set SetPrinter = Nothing

MsgBox Printer.DeviceName & vbCrLf & Printer.DriverName & vbCrLf & _
Printer.Port, vbDefaultButton1, ""
End Sub


See the messageboxes - they show that the default printer is indeed being changed, then restored. Yet the report is still being printed from the "default" printer - that is, its prints like the change never took place, from the original printer, not the newly selected printer.

Now whats most frustrating about this is if i run the above code in a seperate .exe, (a simple combo box which lists printers, and does the above swapping of printers), leave it open after i've changed it to the printer i want, then open the app with the above code in it, it WILL print to the printer that i want to change it to.

I've tried adding the MyReport.PrintOut :

MyReport.SelectPrinter Printer.DriverName, Printer.DeviceName, Printer.Port

But this crashes the app and shuts down vb.

Can anyone help me, i'm getting a bald patch where i'm scratching my head so much.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Automatically Use The Default Printer In Crystal Reports 10
Hi to all,

In retrieving the printers configured in my system and in getting the default printer, all I need to do is use the Printer object in VB?

Does that work? Why is it that some site gave examples in getting the default printer using API calls?

I am also having problems in setting the printer dynamically at runtime using crystal reports.

Thanks and god bless.

List Of Printers To Change Printer In Crystal Reports
I need to have a drop down list of all available printers on the computer so the user can change the printer before trying to print a crystal report. I've seen MKosolf's post on how to do it, parsing the chosen printer from a list and getting the driver name and port from that, but my question is how do I get what the driver name and port are into the list in the first place? I populate a list with:


Code:
Dim x As Printer
For Each x In Printers

listPrinters.AddItem x.DeviceName & ", " & x.Port & ", " & x.DriverName

Next

Is this correct?

Default Values In DTPicker Time Fields - Force User To Change Or Accept Before Saving
I have 2 time fields both of which have default values of 00:00 (One is a start, the other an end). I want to prompt the user to either confirm that a 24hr time difference is correct, or to change the values - I dont want them able to save the form without doing one of these.

My code so far is:

If Time1.Value = Time2.Value Then
If MsgBox ("You have chosen a 24 hour period is this correct? Select YES to confirm or NO to enter correct values", vbYesNo) = vbNo Then
Time1.SetFocus
Else
End If

The message box comes up, but when No is selected nothing happens and my form still saves....

Thanks in advance!

Does Crystal Reports Accept Data From A Named Pipe Or From Sockets?
Does crystal Reports accept data from a named pipe or from sockets?

A pointer(link) to the information would of great help!!

Thanks,
kiran.

How Can I Change The Default Printer At Runtime To Use It With Printer.print Command?
Hi everyone,
I have a little application which uses printer.print command to do some print jobs, of course there are some other things that I print using Data Reports.
When my application starts, I think it instantiates printer object with the default printer (lx300). Once the application is started, there are some options that use printer.print, but there are options that use printer.print too but I need to print them in another printer (ip1000). I have a common dialog that lets me choose the printer, and when I choose ip1000 every printer.print call goes to lx300. I assume there's no way to "reinstantiate" printer object to print in ip1000.
Also, when I close my application ip1000 becomes my default printer. Does the common dialog can select a printer without changing the Windows default printer like Word, Excel. do?

Thanks a lot for your help

How Can I Change The Default Printer At Runtime To Use It With Printer.print Command?
Hi everyone,
I have a little application which uses printer.print command to do some print jobs, of course there are some other things that I print using Data Reports.
When my application starts, I think it instantiates printer object with the default printer (lx300). Once the application is started, there are some options that use printer.print, but there are options that use printer.print too but I need to print them in another printer (ip1000). I have a common dialog that lets me choose the printer, and when I choose ip1000 every printer.print call goes to lx300. I assume there's no way to "reinstantiate" printer object to print in ip1000.
Also, when I close my application ip1000 becomes my default printer. Does the common dialog can select a printer without changing the Windows default printer like Word, Excel. do?

Thanks a lot for your help

Vb/crystal:how To Replace Crviewer Default Printer With Windows Common Dialog Printer
hi all,
I'm trying to create a crystal report through vb.
does anyone know how to replace the default printer ( that comes with crviewer control) with a windows common dialog printer. I mean, with the options to select differnt printers etc.

How To Change The Default Printer?
Hi brains


i am working in a accounting software, i don't know how i change the default printer in run time because i have a different page setup as default for different printer. i am using windows XP/sp2


pls help me .............................................................


with regards

annamalai

Change The Default Printer
I have two printers that have been setup in my computer. One is local and the other is in the network. My program needs to print in those two printers. How can I change the default printer of my computer? Im using vb6 in Windows 98 OS.

Change Default Printer
Hi again,

I want to know how we can change default printer through vb code ?

does anyone know about this stuff ?

Change Default Printer ?
Hello

I need to change the default printer
and then print something from a report.

but it keeps on ending up on the wrong printer.

I think i need to use API bud dont know how.

anybody ?

Thanks in advance
Micke

Change Default Printer In VB
Is there a way to change the default printer. One way suggested in Vb Help is to change the Printer.Device name to the specified printer and then use the set printer statement. But this just sends the output to that printer. I want to change the default printer in start/settings/printer also to show the default printer to the specified printer.
Is there a way in VB or is there an API to do this.
Thanks!

Change Default Printer
Hello!
i amn trying to add a Visuail basic 6 code to an excisting code that has the
purpose to change the current default printer to another printer by name and
then after the printer to change back to the old default printer again...

Anyone knows how to do this easy??

Change The Default Printer In VB 6
Hi!

I want to know how change the default printer through coding in Visual Basic 6.0 also how to set the path to save the PDF file.
I want to create a PDF file from a data report by chaning the default printer to "Acrobat Distiller" and after creating a PDF file the default printer should be changed to the previous one.
Please help me out because I am stucked in this.

Tushar

betrl8thanever: Moved to VB Newbies Forum



Edited by - betrl8thanever on 6/13/2007 9:31:23 PM

How To Change The Default Printer
Please let me know.

Thank you,

How Can You Change Printer From The Default?
How can you change printer from the default? Or print on another printer type \printserver1printer22

Please help

Ola A.

Change The Default Printer
I am developing an application which shows all the installed Printers in a Combo Box. The user depending upon his need selects the Printer from the Combo box and clicks on the Print button provided below. I want to Print to that Printer which the user have selected. But by default it always Prints to the default printer. I am using Printer.Print method for Printing.

Change Default Printer
Hi frients,

How can we change default printer by vb on windows 98?

Thanks,
C.P.Usman

Change The Default Printer
I need to change the default priner on the system

Change Default Printer
I have 2 printers on my computer. I can change default printer through Control Panel or from VB using Common Dialog. How to change default printer from VB code?
Thank you
Vlad

Default Printer Settings For Data Reports
Hi-
This is a probem that has caused allot of head scraching on my part. VB Data Reports must fit on the default printer paper & orientation to go into preview mode. This means that I have to choose my printer setting BEFORE the user sees the report. Is there a way around this, i've tried Unsucessfuly to point the Datareport to the system printer object but for some reason my settings won't stick. I've done the research but I can't find anything of value on the subject. Any help would be appreciated. Thanks
Tarek

Change The Default Windows Printer?
Hi Everyone,

Is there a way to change the default windows printer using VBA in Access??

Thanks,
-Steve

Auto Change Default Printer
Hey guys, why always that i print something (using commondialogbox to select the printer), if the printer is not the default after the printing it will be. It change the computer settings to be the default printer. Any help would be apreciated.
Thanks
Eli

Change Printer Default Setting
how can i change the printer orientation settings without going into the printer dialog box?

Can't Change Default Printer.PaperSize (Please Help)
Hello everybody. I need to fill in and print out some Italian postal forms which are 33 cm long.

The default paper size set on Italian printers is A4, the length of which is only 29.7 cm, so I need to extend it by about 3 cm more or less.

I have set Printer.PaperSize = vbPRPSLegal, since the vbPRPSLegal constant should be equivalent to 35.6 cm but, in spite of this, the printing is truncated after 29.7cm.

Please consider that I compiled my form to an executable before testing the code but it did not work. Here is the incriminated code:


VB Code:
Private Sub Command1_Click()     Printer.ScaleMode = 7    Printer.Orientation = 2        Printer.PaperSize = vbPRPSLegal        Printer.FontName = "Verdana"    Printer.FontSize = 10        Printer.Print ""        Printer.Print "I would very much like this line to be printed out on a 21.6x35.6cm sheet of paper. Unfortunately, it looks like there's no way to change the default settings of my printer which do not want to exceed the 29.7cm height of an A4 page. I know for sure it does not depend on the model of my printer because I have installed someone else's VB6 program which manages to extend the length of the printable area. Why on earth doesn't it work?"        Printer.EndDoc End Sub


I would very much like to know what's wrong with the code above.

Any help will be greatly appreciated.

TIA

Change Printer Locally, Not Set As Default Win
I want an app to only change the printer default within the application. If I use the common dialog, I can set .defaultprinter=False to stop the Windows default printer from changing, but then my local printer isn't changed either!

Code:

Private Sub mnuFPrtSetup_Click()
cmdlg.PrinterDefault = False
cmdlg.Flags = cdlPDPrintSetup
cmdlg.ShowPrinter ' display Printer Setup cdlg box.
VPrint.DeviceName = Printer.DeviceName

End Sub

What can I do to change printers and not change windows defaults?

Change The Default Printer.URGENT!!!!
I'm new in the VB world, and I'm development an application that need change the default printer of the O.S, but without graphic interface.
Can someone help me, please???

Thanks in advanced

Change Default Printer Thru Code
I need to print a word doc. thru a VB application, but to a specific printer. So, I need to do the foll:

1. Change default printer to another, for WORD.
2. Print the specific doc.
3. Change printer back to default printer.

Can anyone help ?

Solution: Default Printer Settings - Data Reports
To reslove issues related to Report Width, Paper Width, Orientation associated with reportwriters that use the printer defaults Ex. MS Data Reports, FoxPro.
Insert the below code into a module and call ChangePaperSize to change the settings and RestorePrinterDefaults to Rollback.
You'll be able to change ANY setting with some modifications.
Please Note that for NT printers the user will need Admin Rights on the Print server OR install the Print drivers localy. Please note that this WILL change your settings and if you don't rollback the settings will remain changed until the user changes them manualy.

The below contains the modified code of the Pageset MS sample.
----------------------------------------
'Constants used in the DevMode structure
Private Const CCHDEVICENAME = 32
Private Const CCHFORMNAME = 32

'Constants for NT security
Private Const STANDARD_RIGHTS_REQUIRED = &HF0000
Private Const PRINTER_ACCESS_ADMINISTER = &H4
Private Const PRINTER_ACCESS_USE = &H8
Private Const PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED Or PRINTER_ACCESS_ADMINISTER Or PRINTER_ACCESS_USE)

'Constants used to make changes to the values contained in the DevMode
Private Const DM_MODIFY = 8
Private Const DM_IN_BUFFER = DM_MODIFY
Private Const DM_COPY = 2
Private Const DM_OUT_BUFFER = DM_COPY
Private Const DM_DUPLEX = &H1000&
Private Const DMDUP_SIMPLEX = 1
Private Const DMDUP_VERTICAL = 2
Private Const DMDUP_HORIZONTAL = 3
Private Const DM_ORIENTATION = &H1&
Private Const DMPAPER_LEGAL As Long = 5
Private Const DMPAPER_LETTER As Long = 1
Private Const DMORIENT_LANDSCAPE As Long = 2
Private Const DMORIENT_PORTRAIT As Long = 1
'and so on

'The DevMode structure contains printing parameters.
'Note that this only represents the PUBLIC portion of the DevMode.
' The full DevMode also contains a variable length PRIVATE section
' which varies in length and content between printer drivers.
'NEVER use this User Defined Type directly with any API call.
' Always combine it into a FULL DevMode structure and then send the
' full DevMode to the API call.
Private Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmLogPixels As Integer
dmBitsPerPel As Long
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
dmICMMethod As Long '// Windows 95 only
dmICMIntent As Long ' // Windows 95 only
dmMediaType As Long ' // Windows 95 only
dmDitherType As Long ' // Windows 95 only
dmReserved1 As Long ' // Windows 95 only
dmReserved2 As Long ' // Windows 95 only
End Type

Private Type PRINTER_DEFAULTS
'Note:
' The definition of Printer_Defaults in the VB5 API viewer is incorrect.
' Below, pDevMode has been corrected to LONG.
pDatatype As String
pDevMode As Long
DesiredAccess As Long
End Type

Public Enum MyPrinterPaperSize
Letter = DMPAPER_LETTER
Legal = DMPAPER_LEGAL

End Enum

Public Enum MyPrinterOrientation
Portrait = DMORIENT_PORTRAIT
Landscape = DMORIENT_LANDSCAPE

End Enum

Private InitialPaperSize As Long
Private InitialPaperOrit As Long
Private CallingHwnd As Long

'------DECLARATIONS

Private Declare Function OpenPrinter Lib "winspool.drv" Alias "OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, pDefault As PRINTER_DEFAULTS) As Long
Private Declare Function SetPrinter Lib "winspool.drv" Alias "SetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal Command As Long) As Long
Private Declare Function GetPrinter Lib "winspool.drv" Alias "GetPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, pPrinter As Any, ByVal cbBuf As Long, pcbNeeded As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal hPrinter As Long) As Long

'The following is an unusual declaration of DocumentProperties:
' pDevModeOutput and pDevModeInput are usually declared ByRef. They are declared
' ByVal in this program because we're using a Printer_Info_2 structure.
' The pi2 structure contains a variable of type LONG which contains the address
' of the DevMode structure (this is called a pointer). This LONG variable must
' be passed ByVal.
' Normally this function is called with a BYTE ARRAY which contains the DevMode
' structure and the Byte Array is passed ByRef.
Private Declare Function DocumentProperties Lib "winspool.drv" Alias "DocumentPropertiesA" (ByVal hwnd As Long, ByVal hPrinter As Long, ByVal pDeviceName As String, ByVal pDevModeOutput As Any, ByVal pDevModeInput As Any, ByVal fMode As Long) As Long


'------CODE

Public Sub ChangePaperSize(MyHwnd As Long, PaperSize As MyPrinterPaperSize, Optional Orientation As MyPrinterOrientation = 0)
Dim PrinterHandle As Long
Dim PrinterName As String
Dim pd As PRINTER_DEFAULTS
Dim MyDevMode As DEVMODE
Dim Result As Long
Dim Needed As Long
Dim pFullDevMode As Long
Dim pi2_buffer() As Long
CallingHwnd = MyHwnd
PrinterName = Printer.DeviceName
If PrinterName = "" Then
Exit Sub
End If

pd.pDatatype = vbNullString
pd.pDevMode = 0&
'Printer_Access_All is required for NT security
pd.DesiredAccess = PRINTER_ALL_ACCESS

Result = OpenPrinter(PrinterName, PrinterHandle, pd)

'The first call to GetPrinter gets the size, in bytes, of the buffer needed.
'This value is divided by 4 since each element of pi2_buffer is a long.
Result = GetPrinter(PrinterHandle, 2, ByVal 0&, 0, Needed)
ReDim pi2_buffer((Needed 4))
Result = GetPrinter(PrinterHandle, 2, pi2_buffer(0), Needed, Needed)

'The seventh element of pi2_buffer is a Pointer to a block of memory
' which contains the full DevMode (including the PRIVATE portion).
pFullDevMode = pi2_buffer(7)

'Copy the Public portion of FullDevMode into our DevMode structure
Call CopyMemory(MyDevMode, ByVal pFullDevMode, Len(MyDevMode))

'Make desired changes
InitialPaperSize = MyDevMode.dmPaperSize
InitialPaperOrit = MyDevMode.dmOrientation
MyDevMode.dmPaperSize = PaperSize
If Orientation <> 0 Then MyDevMode.dmOrientation = Orientation

'Copy our DevMode structure back into FullDevMode
Call CopyMemory(ByVal pFullDevMode, MyDevMode, Len(MyDevMode))

'Copy our changes to "the PUBLIC portion of the DevMode" into "the PRIVATE portion of the DevMode"
Result = DocumentProperties(MyHwnd, PrinterHandle, PrinterName, ByVal pFullDevMode, ByVal pFullDevMode, DM_IN_BUFFER Or DM_OUT_BUFFER)

'Update the printer's default properties (to verify, go to the Printer folder
' and check the properties for the printer)
Result = SetPrinter(PrinterHandle, 2, pi2_buffer(0), 0&)

Call ClosePrinter(PrinterHandle)
End Sub

Public Sub RestorePrinterDefaults()
Dim PrinterHandle As Long
Dim PrinterName As String
Dim pd As PRINTER_DEFAULTS
Dim MyDevMode As DEVMODE
Dim Result As Long
Dim Needed As Long
Dim pFullDevMode As Long
Dim pi2_buffer() As Long

PrinterName = Printer.DeviceName
If PrinterName = "" Then
Exit Sub
End If

pd.pDatatype = vbNullString
pd.pDevMode = 0&
'Printer_Access_All is required for NT security
pd.DesiredAccess = PRINTER_ALL_ACCESS

Result = OpenPrinter(PrinterName, PrinterHandle, pd)

'The first call to GetPrinter gets the size, in bytes, of the buffer needed.
'This value is divided by 4 since each element of pi2_buffer is a long.
Result = GetPrinter(PrinterHandle, 2, ByVal 0&, 0, Needed)
ReDim pi2_buffer((Needed 4))
Result = GetPrinter(PrinterHandle, 2, pi2_buffer(0), Needed, Needed)

'The seventh element of pi2_buffer is a Pointer to a block of memory
' which contains the full DevMode (including the PRIVATE portion).
pFullDevMode = pi2_buffer(7)

'Copy the Public portion of FullDevMode into our DevMode structure
Call CopyMemory(MyDevMode, ByVal pFullDevMode, Len(MyDevMode))

'Make desired changes
MyDevMode.dmPaperSize = InitialPaperSize
MyDevMode.dmOrientation = InitialPaperOrit

'Copy our DevMode structure back into FullDevMode
Call CopyMemory(ByVal pFullDevMode, MyDevMode, Len(MyDevMode))

'Copy our changes to "the PUBLIC portion of the DevMode" into "the PRIVATE portion of the DevMode"
Result = DocumentProperties(CallingHwnd, PrinterHandle, PrinterName, ByVal pFullDevMode, ByVal pFullDevMode, DM_IN_BUFFER Or DM_OUT_BUFFER)

'Update the printer's default properties (to verify, go to the Printer folder
' and check the properties for the printer)
Result = SetPrinter(PrinterHandle, 2, pi2_buffer(0), 0&)

Call ClosePrinter(PrinterHandle)
End Sub

VBScript To Change To System Default Printer
I'm trying to setup a script which will configure the printers on a PC. I've got the following sub's :

Code:
Sub InstallPrinter(PrintShare)
' Configure the Printer
Set WSHShell = CreateObject("WScript.Shell")

WScript.Echo "Connecting to Printer " & PrintShare
'Setup the printer connection

WSHShell.Run "rundll32 printui.dll,PrintUIEntry /ga /n" & PrintShare, 0, true

Set WSHShell = nothing
end sub
and

Code:
Sub SetDefault(DefaultPrinter)
'Sets the default printer to the argument supplied
On Error Resume next
Set objNetwork = CreateObject("WScript.Network")

WScript.Echo "Setting Default Printer to " & DefaultPrinter
objNetwork.SetDefaultPrinter DefaultPrinter

' Any other error, record the result
If Err.Number <> 0 thenWScript.Echo "Couldn't set the default printer (" & Err.Number & "): " & Err.Description

Set objNetwork = Nothing
end sub
The reason I've create the Printers using PrintUIEntry is because it allows me to setup a network printer globally. But then when I use the objNetwork.SetDefaultPrinter method it fails because the Printer doesn't exist. I've put a loop in there to wait for the printer to load... but after 5 minutes it still hadn't.

Is there something i'm missing... or a better way??

Thanks,

Cameron

Updated Code To Change Default Printer On XP ?
Hi,
   Have used code to change the default printer on NT, W2k no problemo, but am having an issue with XP. Does anyone have sample code that works for this on XP ?
Thanks, Steve.

Commondialog - How To Change Default Printer In VB6proSP5?
Can anyone please advise ... seems so simple .. yet ...
Environment is a single PC with three printers - ink jet, laser and postscript - on a switched LPT1. No problem there. But I am trying to change the default printer in VB to the user's printer selection - that doesn't work.

The user's selection changes in the commondialog dropdown but I can't see any property or simple means of finding out in code what it has changed to. And no matter what the user selects, the Printer.Devicename remains set to the pre-existing default printer name.

If I show a private VB6 printer select form - after .Showprinter (below) - and get the printer name that way, and replace Printer.Devicename in the comparison below, it works .. but there must be a better way? Can anyone help please.

             ' TEST SETUP of DEFAULT PRINTER ...

             Dim x as Printer
             With TN6Graf1
                     .CommonDialog1.Flags = cdlPDPrintSetup
                     .CommonDialog1.PrinterDefault = True
                     On Error GoTo CancelHandler
                     .CommonDialog1.CancelError = True
                     
                     .CommonDialog1.ShowPrinter
                                  
                     ' compare user's Printer Name selection and set as default printer

                     For Each x In Printers
                          If x.DeviceName = Printer.DeviceName Then
                               Set Printer = x
                               ' success
                               Exit For
                          End If
                     Next
             End with

             Printer.EndDoc


Thanks a lot .....


Fred Playne

Change Default Printer Setting At Runtime
could anybody give me a sample code to change the default printer's setting (paper width/height,paper source, orientatio) at runtime

How Do I Get Print Dialog To Not Change Default Printer?
Is it possible to use the Print Dialog to select a printer without the current default printer being changed to whatever is selected?

I would like to use the print dialog to allow a user to select a printer. Then use this printer and the print object to print to this printer. I do not want the current default printer to be changed? It seems to me other programs such as Word and Excel do this is it possible in VB?

Do I have to restore the default printer with something else after using the dialog?
I have seen ways to set the default printer and I think I have read in some places that to get the current printer selection from the dialog the default printer has to be changed, but is there another way to get printer selection and settings without changing the default printer?

Here is my code to show the print dialog and print.

With dlgCommonDialog
.DialogTitle = "Print"
.CancelError = True
.Flags = cdlPDReturnDC + cdlPDNoPageNums
If Err <> MSComDlg.cdlCancel Then
Call Print_DR1
End If
End With

Any help would be greatly appreciated!!!!

Crystal Report To Default Printer
Dear all,

We are using VB60 and Crystal Report Control 4.6
How do we get de report "d: estq.rpt" to our default printer? A lot of people can reach the report and have there own default printer.

Nice regards,
Michelle.


CrystalReport1.ReportFileName = "d: estq.rpt"
CrystalReport1.PrinterName = "????"
CrystalReport1.Destination = crptToPrinter
CrystalReport1.MarginLeft = 1
CrystalReport1.Action = 1

Change The Database Location In Crystal Reports Sub Reports From VB During Runtime
I have several reports that were designed in Crystal Reports that have the DB location changed during runtime. When I move my database, or choose another copy of the DB that has a lot of records in it, my reports don't fire. I need to be able to Verify the database during runtime. I'm usiung VB6.0 and CrystalReports8.5 I've tried using Crystal's "Verify On Every Print" function, but I haven't had any luck. Here is the code I am using.

MyLocation = "C:mydatabase.mdb"
CRPE321.ReportFileName = "c:aptcom
eports eninfo.rpt"
CRPE321.DataFiles(0) = MyLocation
CRPE321.ParameterFields(0) = "ThisKey;" & Who.Text & ";true"
CRPE321.PrintReport

Also, does anyone know if changing the DataFiles location during runtime also effects the subreports. I don't think it does, but any input would be appreciative.

Change The Database Location In Crystal Reports Sub Reports From VB During Runtime
I've created a Report Viewer that displays Crystal Reports 8.5 reports. I have the DB location in Crystal Reports changed during runtime, but I can't get the location to change in the subreports at runtime as well. Also, by using my method of calling the reports, I can't get VB to pass any parameters to the Main report. Below is the code that I am using. I'm using VB 6.0 and CR 8.5

Dim MyNewKey
MyNewKey = Who.Text

' On Error GoTo KeepGoing

MyLocation = GetStringValue("HKEY_LOCAL_MACHINESoftwareAptCom", "AptCom DB Path")
strReportFile = "c:aptcom
eports eninfo.rpt"

Set CRReport = New CRAXDRT.Report
Set CrxApp = CreateObject("crystalruntime.application")
Set CRReport = CrxApp.OpenReport(strReportFile)
' Set CRReport.ParameterFields(0) = "ThisKey;" & MyNewKey & ";true"

' KeepGoing:

For Each dbTable In CRReport.Database.Tables
dbTable.SetLogOnInfo "", MyLocation, "", ""
dbTable.Location = MyLocation
dbTable.SetDataSource MyLocation
Next dbTable
CRReport.Database.Verify


CRReport.SQLQueryString = strSQL

frmReportViewer.Show
frmReportViewer.CRViewer1.ReportSource = CRReport
frmReportViewer.CRViewer1.ViewReport

Set CRReport = Nothing
Set CrxApp = Nothing
Set CRReport = Nothing

&gt;&gt;&gt;&gt;
I've tried using this method:

MyLocation = "C:mydatabase.mdb"
CRPE321.ReportFileName = "c:aptcom
eports eninfo.rpt"
CRPE321.DataFiles(0) = MyLocation
CRPE321.ParameterFields(0) = "ThisKey;" & Who.Text & ";true"
CRPE321.PrintReport

But, I can't get Crystal Reports to verify the database during runtime. The first way verifies the DB, but won't change the DB location of the subreports or pass parameters to the reports.

Any help would be appriciative.

Change Default Printer's Paper Size At Runtime
could anybody give me a sample code to change the default printer's setting (paper width/height,paper source, orientation) at runtime

Common Control Change Permantaly The Default Printer
I open a common Control box for user to select the printer to use. Everything goes ok for the printing. The problem is that the printer selected stuck as the default printer even after the program is closed. Here's my code :

comPrinter.CancelError = True
On Error GoTo ErrHandler
comPrinter.ShowPrinter


[Here I call function that set font, font size, and margins]
[Then I print using Printer.Print "text" followed by Printer.EndDoc]


Unload Me
Exit Sub
ErrHandler:
' User pressed Cancel button.
Exit Sub


I'm under visual basic 5, using comdlg32 version 6.0 under Win XP pro.

Thanks a lot for your help

Printing Forms Needs To Change Default Printer Setting
 I have created a Form in XLS which i need to print to a label printer located on USB port. The problem is to print a Form you can only print to the default printer. Which is my A4 printer on a network.

I have found examples to open a listbox and change in another form but this shows local printers only.

- I need to read the current printer (on network) and save as valiable (NWPrinter)
- I need to change the default Printer (on USA)
- I need to printform
- I then need to revert back to NWPrinter otherwise all the documents come out on the label printer.

Can anyone help? i need this from an VB in Excel. Thanks

Change Default Printer Before Using Shell Execute To Print Pdf Dicuments From Excel
hi
I have made program that prints pdf documents from excel using shell execute command. Since I have to print documents differently I have to change the printer to which I send the documents during the run time.
So can anyone tell me how to change the default printer in vba excel. shell execute function only prints to the default printer. Therefore I need to change the default printer.

bye

Crystal Reports - Choose Printer
How can I allow my client to choose the printer they print a report to? I have crystal 8.5 and am calling thr report from a VB application, using the .ocx.

VB Code:
Crystal.ReportFileName = strPath & "Quote.rpt"    Crystal.DataFiles(0) = strPath & "QuoteSystem.mdb"    Crystal.SelectionFormula = "{Quote.QuoteNo} = " & cboQuoteNo.Text    Crystal.Destination = crptToPrinter    errCry = Crystal.PrintReport
But this sends the report to the default printer. I want the user to be able to choosee from the list of installed printers.

Please include an example and any references with reponse. Thanks

Printing To Any Printer In Crystal Reports
Hello,

I have a question about printing in Crystal Reports.
When you apply the Print-button in the report viewer, the document
is automatically send to the default-printer.
Is there a possibility (a setting in Crystal Reports?) to show a list of all the printers to the user, so he can choose which printer to print on.

Greetings, Ulricke

Crystal Reports Printer Dialogue
Is there a way to set the print variables in code and have a Crystal Report print (from a VB app) without showing the printer dialogue?

Select Printer - Crystal Reports 8
Hi there!


I'm using VB6 + CR 8 RDC + CRViewer.

I need to make it available for the user to choose the printer he wants the report to be printed.

Thanks for all your attention!

Crystal Reports And Printer Prompts
How can I "turn off" the printer prompt in Windows 2000 so that documents printed from a webpage will always go to the default printer without prompting the user? I am deploying a web app on wall-mounted kiosks with an attached scanner and am trying to avoid keyboarding or mousing as their only function is to scan, then print - but I cant get rid of the stupid printer prompt!

Reports are runningon an asp page in crystal reports activex smartviewer (version 8)

any help is greatly appreciated!

Select A Printer Programatically For Crystal Reports 10
I have an application in VB 6 which prints reports in Crystal Reports 10 without user prompting. I need to programatically change the printer depending on the report. I tried with "call CRreport.selectprinter (PrinterDrv, PrinterName,PrinterPort)" and with "set printer = MyChosenPrinter" but the program prints always in the system's printer.
Thank you for your help. I need it!

Crystal Reports RDC / Allow User To Select Printer
I need to know how to allow the user to select a printer when printing Crystal reports as opposed to just sending to the default printer.

I am currently designing my reports using RDC. I have a single form (frmRptView), with only the CRViewer control, which I call to view all of my reports.

Here is the code I am using to view a report:

Private Sub cmdViewReport_Click()

Dim Report As New NameOfReport

With frmRptView
.CRViewer1.ReportSource = Report
.Show
.CRViewer1.ViewReport
End With

End Sub

Now I am looking to find the code to utilize under the CRViewer1_PrintButtonClicked event procedure to allow the user to select printer. Under Crystal Care Technical Support I found the following code:

Private Sub CRViewer1_PrintButtonClicked(UseDefault As Boolean)

'Do not use the default printer dialog
UseDefault = False

'Display the Windows Standard Printer Setup dialog box.
Report.PrinterSetup Form1.hWnd

'Print the report without displaying the default printer dialog.
'If the option to set the number of pages is required then
'pass a value of True.
Report.PrintOut False

End Sub

Problems:

1> In my form (with the CRViewer1 control), it does not recognize Report as object.

2> If I hardcode in the name of the report it asks me to enter parameter values. I should mention this is a paramaterized report.

So first things first, If someone could tell me how I can refer to the report from the form which I view the report that would be a start.

Printer Selection Using Crystal Reports Crviewer
Is there any way to ask the user which printer to print to using the crviewer component? I get the report loaded up just fine, but upon clicking the print button...



it doesn't ask which printer to print to, just automatically selects the default.

Any suggestions?



Edited by - eps on 8/23/2004 11:16:49 AM

Copyright © 2005-08 www.BigResource.com, All rights reserved