How To Get Printer Dialog Not to Change Default Printer 
Author Message
 How To Get Printer Dialog Not to Change Default Printer

I have a routine that uses the VB common dialog for printing to format and
print data from a rich text box.  The PrinterDefault property is set to true
so when the user selects a printer in the print dialog, it changes the
user's default printer to the one they selected.  Unfortunately, I need to
use the same code in a situation where the users do not want the default
printer changed.

I am trying to get the print dialog to work like Word, where a different
printer can be selected and used for printing with no changes to the users's
printers.  I have changed this property of the Print dialog to false but
have not been able to print to any other printers than the default.  TIA for
any assistance, I can post the code I'm using to print (it essentially uses
the Printer object).

Dianne Siebold



Mon, 24 Jun 2002 03:00:00 GMT  
 How To Get Printer Dialog Not to Change Default Printer
hi dianne,

try this, it should do the trick:

Legen Sie ein neues ActiveX-Exe-Projekt an
Geben Sie dem Projekt einen Namen, z.B. "DlgActX"
Geben Sie dem Klassenmodul einen Nanmen, z.B. "DlgClass"
Kopieren Sie folgenden Quell-Code in das Klassenmodul:

   Private Sub Class_Initialize()
     With invForm.CommonDialog1
       .Flags = cdlPDPrintSetup
       .ShowPrinter
     End With
     Printer.Orientation = vbPRORPortrait 'oder vbPRORLandscape
   End Sub

   Private Sub Class_Terminate()
      Unload invForm
   End Sub

W?hlen Sie DATEI - DlgActX.Exe erzeugen
Stellen Sie unter PROJEKT - EIGENSCHAFTEN - KOMPONENTE "Bin?rkompatibilit?t"
ein (Damit verhindern Sie, da? bei jedem Compilerdurchlauf eine neue
Class-ID erzeugt wird)
Speichern Sie das Projekt und das Klassenmodul

Damit ist die ActiveX-Exe erstellt und Sie k?nnen sie testen:
Legen Sie ein neues Standard-Exe-Projekt an
Stellen Sie einen Verweis auf DlgActX her (PROJEKT - VERWEISE)
Fgen Sie einen Button auf der Form ein
Kopieren Sie folgenden Quell-Code in das Code-Fenster:

   Private Sub Command1_Click()
     Dim MyDlg As DlgClass
     Set MyDlg = New DlgClass

     ' hier steht dann Ihr eigener Code, z.B.:
     Printer.FontSize = 30
     Printer.Print Printer.DeviceName
     Printer.EndDoc

     Set MyDlg = Nothing 'Speicher wieder freigeben
   End Sub

Starten Sie das Projekt und klicken Sie auf den Button
Nach dem Schlie?en des Printer-Setup-Dialoges wird der korrekte Drucker
angezeigt



Quote:
> I have a routine that uses the VB common dialog for printing to format and
> print data from a rich text box.  The PrinterDefault property is set to
true
> so when the user selects a printer in the print dialog, it changes the
> user's default printer to the one they selected.  Unfortunately, I need to
> use the same code in a situation where the users do not want the default
> printer changed.

> I am trying to get the print dialog to work like Word, where a different
> printer can be selected and used for printing with no changes to the
users's
> printers.  I have changed this property of the Print dialog to false but
> have not been able to print to any other printers than the default.  TIA
for
> any assistance, I can post the code I'm using to print (it essentially
uses
> the Printer object).

> Dianne Siebold



Thu, 27 Jun 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using Printer common dialog changes default printer

2. Changing Printers property reset printer to Windows default printer

3. Macro to change default printer and then restore original default printer settin

4. Getting default printer name from Printers Collection

5. Macro that selects printer and prints doc also changes default printer

6. Problem setting the active printer of Word 97 without changing the Windows default printer

7. Common dialog control changes default printer

8. Printing to a printer that is NOT the default printer

9. Problem printing to printer wich is not the default printer

10. Printer object not applying to the default printer ???

11. Common Dialog - Does not follow default printer

12. Want Printer SetUp, not Printer Dialog

 

 
Powered by phpBB® Forum Software