Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Print a Text file

Reply
 
Old 10-13-2009   #1 (permalink)
vqthomf


 
 

Print a Text file

Hi I have created a text file in vba and I need to print the file without the
user opening it first, I have tried using excel import and print this works
but cuts some of the text off. I was wondering if it can be printed by send
the text file to the printer??.
Any help would be much appreciated.
Charles

My System SpecsSystem Spec
Old 10-13-2009   #2 (permalink)
mayayana


 
 

Re: Print a Text file

There might be a better option than this, but you
could try it:
IE has an ExecWB method that basically provides access
to common menu items. And IE will load a text file as plain
text. (You could also, conceivably, use the DOM once the
file is loaded to change the font, etc.)
If you load the file into an IE instance using IE.Navigate then
you should be able to print it using:

IE.ExecWB 6, 2 ' -- (print, don't prompt user)


Quote:

> Hi I have created a text file in vba and I need to print the file without
the
Quote:

> user opening it first, I have tried using excel import and print this
works
Quote:

> but cuts some of the text off. I was wondering if it can be printed by
send
Quote:

> the text file to the printer??.
> Any help would be much appreciated.
> Charles

My System SpecsSystem Spec
Old 10-17-2009   #3 (permalink)
mr_unreliable


 
 

Re: Print a Text file

vqthomf wrote:
Quote:

> Hi I have created a text file in vba and I need to print the file without the
> user opening it first, I have tried using excel import and print this works
> but cuts some of the text off. I was wondering if it can be printed by send
> the text file to the printer??.
hi Vqthomf,

If you don't mind using a 3rd Party control, then you can print
directly from script without resorting to notepad, IE, or other
utility.

There is (at least) one, which is simply a wrapper for the vb
printer object, written by Lee Peedin, and found here (look for
"PrinterObject2.zip" about half-way down the page):

http://pragmaticlee.safedataisp.net/

While Lee's actX printer object was written for use with the
REXX scripting language, it will work perfectly well with
vbscript. Or, if you don't trust Lee, then you can write
an actX wrapper for the vb printer object yourself (provided
you have a copy of "classic" vb). It is easy to do, so easy
that I did it myself.

Here is Lee's vbs ng posting about his actX object:

http://groups.google.com/group/micro...7fb716b968f3ad

Since it is a wrapper for the vb printer object, the documentation
is the same as the documentation for the vb printer object itself,
(after you get the P.O. instantiated).

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Convert hostname text file to IP text file VB Script
Looping Through A Text File To Find Patterns From Another Text Fil PowerShell
Howto: Add lines of text from a specific point in a text file.. VB Script
I cannot print the text that come with the emails Vista mail
How do I read a text file and sort text by fixed positions? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46