Home > Archive > Visual Basic > November 2004 > Printing to a specific printer
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Printing to a specific printer
|
|
| RicardoFurtado 2004-09-15, 3:55 pm |
| How can i print to a printer without asking the user to choose the printer,
in order for the document to be printed in the printer desired by the
software?
| |
|
|
You need to know the name of the printer...
dim objPrn as printer
strDevName ="printer device name"
for each objPrn in printers
if objPrn.DeviceName = strDevName then
set Printer = objPrn
exit for
end if
next
Good luck!
Saga
"RicardoFurtado" <RicardoFurtado@discussions.microsoft.com> wrote in
message news:99CB336A-577D-41EA-8035-96189EF57D78@microsoft.com...
> How can i print to a printer without asking the user to choose the
printer,
> in order for the document to be printed in the printer desired by the
> software?
>
| |
| molonede 2004-11-23, 3:55 pm |
| This doesn't seem to work for me. It always prints to the system's default
printer. Any ideas?
"Saga" wrote:
>
> You need to know the name of the printer...
>
> dim objPrn as printer
>
> strDevName ="printer device name"
>
>
> for each objPrn in printers
> if objPrn.DeviceName = strDevName then
> set Printer = objPrn
> exit for
> end if
> next
>
> Good luck!
> Saga
>
> "RicardoFurtado" <RicardoFurtado@discussions.microsoft.com> wrote in
> message news:99CB336A-577D-41EA-8035-96189EF57D78@microsoft.com...
> printer,
>
>
>
| |
| Jan Hyde 2004-11-23, 3:55 pm |
| "molonede" <molonede@discussions.microsoft.com>'s wild
thoughts were released on Tue, 23 Nov 2004 08:59:04 -0800
bearing the following fruit:
>This doesn't seem to work for me. It always prints to the system's default
>printer. Any ideas?
Post a code sample which demonstrates your problem.
[color=darkred]
>"Saga" wrote:
>
Jan Hyde (VB MVP)
--
"My favorite statue is the Venus de Milo," said Tom disarmingly.
(Richard Lederer)
[Abolish the TV License - http://www.tvlicensing.biz/]
| |
| molonede 2004-11-24, 3:55 pm |
| Its the same code that was mentioned. My problem is that it always prints to
the system's default printer. It appears that I have to make a windows call
to change the system default printer then it will print. I was hoping to
avoid the switching of the default printer.
"Jan Hyde" wrote:
> "molonede" <molonede@discussions.microsoft.com>'s wild
> thoughts were released on Tue, 23 Nov 2004 08:59:04 -0800
> bearing the following fruit:
>
>
> Post a code sample which demonstrates your problem.
>
>
>
>
>
>
> Jan Hyde (VB MVP)
>
> --
> "My favorite statue is the Venus de Milo," said Tom disarmingly.
>
> (Richard Lederer)
>
> [Abolish the TV License - http://www.tvlicensing.biz/]
>
>
| |
| Jan Hyde 2004-11-24, 3:55 pm |
| X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 87
NNTP-Posting-Host: 213.249.143.234
X-Trace: sv3-yCIFy/ JvXOvZgzR1HEvOwLWWZrkpXTJLVXPzst1qwTufwo
tKO4YcPrXvSV3TYGT0nA9I1TEzgFODTlF!OzWuyk
fpudIgem+C8meJHgdfOfQ5uH+/YGK54qSmCsS8VB+kieUqXSY6/JVqx/SoK02Je3IFqrY5!aDmExlNe6xY4
X-Complaints-To: abuse@karoo.kcom.com
X-DMCA-Complaints-To: abuse@karoo.kcom.com
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.20
Path: TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.karoo.co.uk!news.karoo.co.uk.POSTED!not-for-mail
Xref: TK2MSFTNGP08.phx.gbl microsoft.public.vb.general.discussion:532867
"molonede" <molonede@discussions.microsoft.com>'s wild
thoughts were released on Wed, 24 Nov 2004 08:21:06 -0800
bearing the following fruit:
>Its the same code that was mentioned.
I can only see the messages I replied to. Neither contain
code to print anything. I'd like to see a code sample which
selects the printer, then prints something (to the wrong
printer) so that I can test it here.
>My problem is that it always prints to
>the system's default printer. It appears that I have to make a windows call
>to change the system default printer then it will print. I was hoping to
>avoid the switching of the default printer.
Also, which OS are you using?
J
[color=darkred]
>"Jan Hyde" wrote:
>
Jan Hyde (VB MVP)
--
We got divorced because of illness;
We got sick of each other. (Henny Youngman)
[Abolish the TV License - http://www.tvlicensing.biz/]
| |
| molonede 2004-11-24, 3:55 pm |
| dim objPrn as printer
"Jan Hyde" wrote:
[color=darkred]
> "molonede" <molonede@discussions.microsoft.com>'s wild
> thoughts were released on Wed, 24 Nov 2004 08:21:06 -0800
> bearing the following fruit:
>
>
> I can only see the messages I replied to. Neither contain
> code to print anything. I'd like to see a code sample which
> selects the printer, then prints something (to the wrong
> printer) so that I can test it here.
>
>
> Also, which OS are you using?
>
> J
>
>
>
>
> Jan Hyde (VB MVP)
>
> --
> We got divorced because of illness;
> We got sick of each other. (Henny Youngman)
>
> [Abolish the TV License - http://www.tvlicensing.biz/]
>
>
| |
| U-CDK_CHARLES\\Charles 2004-11-24, 8:55 pm |
| Reply-To: cdkrug@aol.com
User-Agent: slrn/0.9.8.0 (CYGWIN_NT-5.1)
Lines: 21
Message-ID: <Pw6pd.8702$sX5.4489@trndny05>
Date: Wed, 24 Nov 2004 20:53:03 GMT
NNTP-Posting-Host: 68.239.238.131
X-Complaints-To: abuse@verizon.net
X-Trace: trndny05 1101329583 68.239.238.131 (Wed, 24 Nov 2004 15:53:03 EST)
NNTP-Posting-Date: Wed, 24 Nov 2004 15:53:03 EST
Path: TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny05.POSTED!143200e9!not-for-mail
Xref: TK2MSFTNGP08.phx.gbl microsoft.public.vb.general.discussion:532897
On Wed, 24 Nov 2004 08:21:06 -0800, molonede
<molonede@discussions.microsoft.com> wrote:
> Its the same code that was mentioned. My problem is that it always prints to
> the system's default printer. It appears that I have to make a windows call
> to change the system default printer then it will print. I was hoping to
> avoid the switching of the default printer.
>
I was struggling with the same problem. You can download a control from
Microsoft that returns values to assign to a printer object.
Our application has several "fixed" printers for various multipart
forms, plus a standard Win Print dialog. We use this control at setup
time to assign the various multipart printers.
So far so good.
Take a look here:
http://support.microsoft.com/defaul...kb;en-us;322710
| |
| Jan Hyde 2004-11-25, 8:55 am |
| "molonede" <molonede@discussions.microsoft.com>'s wild
thoughts were released on Wed, 24 Nov 2004 09:17:03 -0800
bearing the following fruit:
[color=darkred]
>dim objPrn as printer
Ok, your not helping.
That code does **not** print anything.
I'd like to see a code sample which selects the printer,
then ***prints something*** (to the wrong printer) so that I
can test it here.
Again, which OS are you using?
J
[color=darkred]
>
>"Jan Hyde" wrote:
>
Jan Hyde (VB MVP)
--
Nostalgia is like a grammar lesson: You find the present tense and the past perfect. (Catherine Shoemaker)
[Abolish the TV License - http://www.tvlicensing.biz/]
| |
| NickHK 2004-11-26, 3:55 am |
| molonede,
From a later thread, ("Set Printer in VB6"), there was this code, note the
extra last line:
Dim strDesiredDeviceName As String
strDesiredDeviceName = "CPOE Printer"
For Each prt In Printers
If prt.DeviceName = strDesiredDeviceName Then
Set Printer = prt
Exit For
End If
Next
DataReport1.PrintReport <=====
Does this not mean that VB will go to the default printer for this data
report ? You are not using the Printer object that you set in code.
Using "Set Printer=prt" will only affect the printer used by Printer.xxx
commands, as you are expressly not changing the default printer.
Unless I'm wrong, which is quite possible.
NickHK
"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
news:c88bq0569202qj5q6533le9d4ee44s5572@
4ax.com...
> "molonede" <molonede@discussions.microsoft.com>'s wild
> thoughts were released on Wed, 24 Nov 2004 09:17:03 -0800
> bearing the following fruit:
>
>
>
> Ok, your not helping.
>
> That code does **not** print anything.
>
> I'd like to see a code sample which selects the printer,
> then ***prints something*** (to the wrong printer) so that I
> can test it here.
>
> Again, which OS are you using?
>
> J
>
>
>
>
>
>
>
>
windows call[color=darkred]
to[color=darkred]
default[color=darkred]
in[color=darkred]
news:99CB336A-577D-41EA-8035-96189EF57D78@microsoft.com...[color=darkred]
the[color=darkred]
by the[color=darkred]
>
>
> Jan Hyde (VB MVP)
>
> --
> Nostalgia is like a grammar lesson: You find the present tense and the
past perfect. (Catherine Shoemaker)
>
> [Abolish the TV License - http://www.tvlicensing.biz/]
>
| |
| Jan Hyde 2004-11-26, 8:55 am |
| "NickHK" <TungCheWah@Invalid.com>'s wild thoughts were
released on Fri, 26 Nov 2004 11:47:02 +0800 bearing the
following fruit:
>molonede,
>From a later thread, ("Set Printer in VB6"), there was this code, note the
>extra last line:
>
> Dim strDesiredDeviceName As String
> strDesiredDeviceName = "CPOE Printer"
> For Each prt In Printers
> If prt.DeviceName = strDesiredDeviceName Then
> Set Printer = prt
> Exit For
> End If
> Next
> DataReport1.PrintReport <=====
Thank you! It's a shame the OP doesn't feel that this is
important information.
>Does this not mean that VB will go to the default printer for this data
>report ? You are not using the Printer object that you set in code.
>Using "Set Printer=prt" will only affect the printer used by Printer.xxx
>commands, as you are expressly not changing the default printer.
>
>Unless I'm wrong, which is quite possible.
I've never used the datareport but IIRC you are right. The
Datareport uses the default printer.
J
>NickHK
>
>
>"Jan Hyde" <StellaDrinker@REMOVE.ME.uboot.com> wrote in message
> news:c88bq0569202qj5q6533le9d4ee44s5572@
4ax.com...
>windows call
>to
>default
>in
>news:99CB336A-577D-41EA-8035-96189EF57D78@microsoft.com...
>the
>by the
>past perfect. (Catherine Shoemaker)
>
Jan Hyde (VB MVP)
--
Varicose: Not very far. (Jimmy Snibbler)
[Abolish the TV License - http://www.tvlicensing.biz/]
| |
| molonede 2004-11-29, 3:56 pm |
| Thanks, I tried this and it does not change the results. It appears that the
Data Report Object will only print to the system's default printer. Where
using the Data Report object?
"U-CDK_CHARLES\\Charles" <"Charles Krug" wrote:
> On Wed, 24 Nov 2004 08:21:06 -0800, molonede
> <molonede@discussions.microsoft.com> wrote:
>
> I was struggling with the same problem. You can download a control from
> Microsoft that returns values to assign to a printer object.
>
> Our application has several "fixed" printers for various multipart
> forms, plus a standard Win Print dialog. We use this control at setup
> time to assign the various multipart printers.
>
> So far so good.
>
> Take a look here:
>
> http://support.microsoft.com/defaul...kb;en-us;322710
>
>
| |
| molonede 2004-11-29, 3:56 pm |
| Jan, sorry about the confusion on the datareport.pring missing, forgot to
copy it. So I am assuming from the last set of responses that the data
report object only prints to the system's default printer and there is no way
to change it?
"Jan Hyde" wrote:
> "NickHK" <TungCheWah@Invalid.com>'s wild thoughts were
> released on Fri, 26 Nov 2004 11:47:02 +0800 bearing the
> following fruit:
>
>
> Thank you! It's a shame the OP doesn't feel that this is
> important information.
>
>
> I've never used the datareport but IIRC you are right. The
> Datareport uses the default printer.
>
> J
>
>
>
> Jan Hyde (VB MVP)
>
> --
> Varicose: Not very far. (Jimmy Snibbler)
>
> [Abolish the TV License - http://www.tvlicensing.biz/]
>
>
| |
| Jan Hyde 2004-11-29, 3:56 pm |
| "molonede" <molonede@discussions.microsoft.com>'s wild
thoughts were released on Mon, 29 Nov 2004 06:19:01 -0800
bearing the following fruit:
>Jan, sorry about the confusion on the datareport.pring missing, forgot to
>copy it.
Unfortunately, that was the only relevent line of code.
>So I am assuming from the last set of responses that the data
>report object only prints to the system's default printer and there is no way
>to change it?
It seems so. I doubt the datareport gets used much.
[color=darkred]
>
>"Jan Hyde" wrote:
>
Jan Hyde (VB MVP)
--
A forger is a man who made a name for himself. (Henny Youngman)
[Abolish the TV License - http://www.tvlicensing.biz/]
|
|
|
|
|