From: Webbiz on
Hello.

I'm trying to write a routine to print the form currently with the
focus.

I'd like to select which printer to use when the print menu item is
selected, without changing the Default printer for the whole system.

For printing the form, I tried to use PrintForm. It did print the
form, except it failed to include the items was were displayed within
a picturebox that was on the form. The buttons printed, the grids, the
frames, radio buttons, etc. The Title bar did not, nor the drawing
that was inside the picturebox. It shows blank when printed.

Also, the darn thing chopped part of the right side of the form when
printed.

I've Googled several examples but found many were very long winded and
seemed to account for every possible setting. I'm trying to make this
as minimal as possible.

Is PrintForm the way to go, or is using it why I'm having some of
these problems?

Thanks.

Webbiz
From: mayayana on
Apparently this is Mike William's day off...

This might help for getting the picture, but I
don't know about selecting printers. The following
is something I've used for getting a Desktop
screenshot:

http://vbnet.mvps.org/code/bitmap/printscreenole.htm

It's a method for returning an image of the
Desktop as a .bmp. If you just substitute the width,
height, etc. where relevant with the RECT of the window
in question you can get a snapshot of that window.


> I'm trying to write a routine to print the form currently with the
> focus.
>
> I'd like to select which printer to use when the print menu item is
> selected, without changing the Default printer for the whole system.
>
> For printing the form, I tried to use PrintForm. It did print the
> form, except it failed to include the items was were displayed within
> a picturebox that was on the form. The buttons printed, the grids, the
> frames, radio buttons, etc. The Title bar did not, nor the drawing
> that was inside the picturebox. It shows blank when printed.
>
> Also, the darn thing chopped part of the right side of the form when
> printed.
>
> I've Googled several examples but found many were very long winded and
> seemed to account for every possible setting. I'm trying to make this
> as minimal as possible.
>
> Is PrintForm the way to go, or is using it why I'm having some of
> these problems?
>
> Thanks.
>
> Webbiz


From: Webbiz on
(Note: I'm top posting only because the reply to my original post is a
top post. Please do not shoot me! :)

Thanks mayayana.

I'll try to give the screenshot idea a 'shot' (pun).

I'm thinking that the PrintForm method would be the easy way to handle
this, although it seems to have left off the title bar and didn't
print everything showing on the form (that which is inside the
picbox).

Perhaps the screenshot is the only way to handle it.

I'm also trying to set it up where the user can first select the
printer. Yet, I don't want the default printer changed for any other
application.

I came across this info, but it's a lot of information for what I'm
thinking is overkill. That's why I was hoping someone could steer me
towards a very simple solution.

http://www.codeguru.com/forum/showthread.php?s=&threadid=250928

Thank you for replying.

:-)

Webbiz




On Fri, 6 Nov 2009 12:10:34 -0500, "mayayana" <mayaXXyana(a)rcXXn.com>
wrote:

> Apparently this is Mike William's day off...
>
> This might help for getting the picture, but I
>don't know about selecting printers. The following
>is something I've used for getting a Desktop
>screenshot:
>
>http://vbnet.mvps.org/code/bitmap/printscreenole.htm
>
> It's a method for returning an image of the
>Desktop as a .bmp. If you just substitute the width,
>height, etc. where relevant with the RECT of the window
>in question you can get a snapshot of that window.
>
>
>> I'm trying to write a routine to print the form currently with the
>> focus.
>>
>> I'd like to select which printer to use when the print menu item is
>> selected, without changing the Default printer for the whole system.
>>
>> For printing the form, I tried to use PrintForm. It did print the
>> form, except it failed to include the items was were displayed within
>> a picturebox that was on the form. The buttons printed, the grids, the
>> frames, radio buttons, etc. The Title bar did not, nor the drawing
>> that was inside the picturebox. It shows blank when printed.
>>
>> Also, the darn thing chopped part of the right side of the form when
>> printed.
>>
>> I've Googled several examples but found many were very long winded and
>> seemed to account for every possible setting. I'm trying to make this
>> as minimal as possible.
>>
>> Is PrintForm the way to go, or is using it why I'm having some of
>> these problems?
>>
>> Thanks.
>>
>> Webbiz
>
From: Nobody on
"Webbiz" <nospam(a)forme.thanks.com> wrote in message
news:p6c7f51rqmsjpf005oj20u377ntlm7057i(a)4ax.com...
> I'd like to select which printer to use when the print menu item is
> selected, without changing the Default printer for the whole system.

See "Printers collection" in MSDN. I think the example is incorrect in
stating that "Set printer as system default.". It rather sets it application
wide. Also, if you are using the common print dialog, the user can change
the printer from it, so you need some code to switch Printer object to what
the user selected. Search MSDN by title only for "Using the Print Dialog
Box". The example below loops through Printers collection, and selects one
by name.

Option Explicit

Private Sub Form_Load()
Dim i As Long

For i = 0 To Printers.Count - 1
Debug.Print Printers(i).DeviceName
If Printers(i).DeviceName Like "*HP*" Then
Set Printer = Printers(i)
Exit For
End If
Next
If i = Printers.Count Then
Debug.Print "No matching printer found."
End If
End Sub


From: Eduardo on
In VB you can change the printer like this:

Dim prn As Printer
Dim iDesiredPrinterName As String
Dim iFound As Boolean

iDesiredPrinterName = "Printer Name"

For Each prn In Printers
If prn.DeviceName = iDesiredPrinterName Then
Set Printer = prn
iFound = True
End If
Next prn
If Not iFound Then
MsgBox "Printer '" & iDesiredPrinterName & _
"' not found", vbInformation
End If

This does not affect Windows's default printer.