Changing default printer using API calls
Tony,
Try something like the following (I am typing this as I go so please
forgive any typos, syntax, etc).
Private Sub Command1_Click()
Dim p As Printer
For each p in Printers
If p.DeviceName = strTill Then
Set Printer = p
Printer.Font = "Arial"
Printer.Print "Till printout"
End If
If p.DeviceName = strOrder Then
Set Printer = p
Printer.Font = "Courier"
Printer.Print "Order printout"
End If
Next p
End Sub
Kevin Williamson - Microsoft Visual Basic Support
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved.
--------------------
| Newsgroups: microsoft.public.vb.enterprise
| Subject: Changing default printer using API calls
| Date: Tue, 18 Sep 2001 08:59:02 +0200
| Lines: 33
| Organization: Databus
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 5.00.2014.211
| X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
| NNTP-Posting-Host: 196.7.49.244
| X-Trace: 18 Sep 2001 08:55:29 +0200, 196.7.49.244
| Path:
cppssbbsa01.microsoft.com!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de
!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-hog.berkeley.edu!ucber
keley!enews.sgi.com!iafrica.com!news1.mweb.co.za!196.7.49.244
| Xref: cppssbbsa01.microsoft.com microsoft.public.vb.enterprise:62390
| X-Tomcat-NG: microsoft.public.vb.enterprise
|
| Hi All,
|
| I need to print to two different printers in quick succession WITHOUT ANY
| USER INTERVENTION. Till slip on one, Order on another. I can
successfully
| change the default printer using API calls and the printing works just
fine
| using Printer.Print until I try to set the font for the 2nd printer. The
| moment I access Printer.Fonts in any way, the printing happens on the
first
| printer.... It is as if the fonts object does not come along with the
| default, so accessing the fonts nullifies the setting of the default
printer
| to printer 2.
|
| Microsoft acknowledges this as a bug in VB3 and claims it was fixed in
VB4.
| The example they give calls the common dialog to set the default printer
and
| then to check the font count, so it seems as if the common dialog was
fixed.
| Using API calls it seems to not be resolved. From what I can gather I
need
| to use a DLL written in C++ to call EnumFonts or EnumFontFamilies.
|
| Does anyone know if I can call these functions from within VB and what the
| parameters mean?
| EnumFonts parameters: hDC as Long, lpsz as string, lpFontEnumProc as Long,
| lParam as Long
| EnumFontFamilies parameters: hDC as Long, lpszFamily as String,
| plEnumFontFamProc as Long, lParam as Long.
|
| Please help,
|
| Tony Robson.
|
|
|
|
|
|
|