Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

= command for type abc.txt>prn (Dos command) 1

Status
Not open for further replies.

shanmugham

Programmer
Jun 19, 2001
71
IN
i have a text file abc.txt
i have only dot matrix printer
i want to print that file

i tried through vb code with line input command it works fine

but the problem is our printer prints each character
by half and half(double times in each chr) like Doc print type

but in dos command
======================
type abc.txt>prn
======================
it print each character by a single impression
its fine

i tried opening that text file thru notepad
it works but the problem is, it print file names and page number. how to solve the problem

so i need equivalent command for
the above DOS Command

thanks in advance
shan
 
You could use the "shell" command - it would something like Shell "type abc.txt>prn"

hope it helps...
 
thanks TomKane

i need full command for this please ....

help ...

shan
 
thanks TomKane
i have no idea for this shell command
i need full code for this please ....
help me

shan
 
Hi,

This is the full command line:

Shell "Type Abc.Txt>prn", vbNormalFocus

the only thing is that you may have to put in the pathname as to where the file actually is.
 
thanks TomKane
its working fine ..
i am new in vb
but i need dynamic file name printing

fname = text1.text
'text1.text values , it contain files name abc.txt

Shell "Type fname>prn", vbNormalFocus
it is not working

it gives problem

shan



 
Try this:

Shell "Type " & fname & ">prn", vbNormalFocus

hope it helps
 
thanks, but it give the problem
i typed the command
shell "type c:\ec\ecrpt.txt>prn",vbnormalfocus

it gives the erro
runtime error 53
file not found
i checked that file is available
pl check sir

hel me
thanks
shan
 
thanks, but it give the Error
i typed the command
shell "type c:\ec\ecrpt.txt>prn",vbnormalfocus

it gives the error
==================
runtime error 53
file not found
==================
i checked again and again that file is available in the c:\ec\ecrpt.txt
this is very urgent pl...
pl check sir
help me
thanks
shan
 
Hi,

The 'Type' command, is internal Command.com and emulated by windows, when running a shell window, thus it is not avaiable a a file!. If you try the command you wrote in the windows Start->Run, it will give the same message (File could not be found...)

Hope this helps,

Carlos Paiva
 
Thanks Carlos
but i done Start->Run->command.com
type c:\ec\ecrpt.txt>prn
it works fine, it prints the content of the file
pl check
shan
 
Hi,

Try using the parameters on command.com.

I dont have command.com because im on win2k. if i do (in DOS)

Cmd /?

- it gives me a list of the parameters.

I can see that /C - executes the command then exits - which is exactly what you want.

thus it will work from Start -> Run

cmd /c type d:\r.txt | more

in Vb

Shell "cmd /c type " & filename & " > " & outputfile

Substitute Command for cmd, but you will need to check if the parameters are the same - im not sure if they are.

Also printing from Notepad, you can turn off the Page numbers etc (go File -> Page Setup).

Rich.

 
Actually this program is to print pre printed stationary thru dot matrix printer

shell "cmd/c type "&filename & ">" &outputfile

was also gives the same error mesg

pl give alternate method pl,..

shan
 
windows xp

i checked both

i think, add any properties or any commnd for the declaration section

shan
 
Hi,

Firstly, for WinXP use cmd. You may have also command - but i think it is better to use cmd.

Next, if you are getting File not found error when the Shell command is executed, then vb cannot find the filename of the command. Can you run the same command from the Start-> Run ?

Finally, After doing a quick search from google it seems that printing from DOS, specifically using PRN, is not supported in NT, 2K, ME, XP. But there is a way around it :

which came from

Good luck.
Rich.
 
Hi,
>but i done Start->Run->command.com

So your command is command.com, as i said.
You should pass to VB:
Shell "Command type c:\ec\ecrpt.txt>prn",vbnormalfocus
But i'm not sure if command.com accepts internal commands as parameters!
I' dont think this is possible...
I didn't try it!

Tell me, if i'm wrong

Hope this helps you.
Carlos Paiva
 
The following works ok (type file contents into another file):

Dim rtn As Long
rtn = Shell("cmd /c type c:\sdsrollerr.txt >c:\ar123.txt", vbNormalFocus)

so the following should work:

Dim rtn As Long
rtn = Shell("cmd /c type c:\sdsrollerr.txt >lpt1", vbNormalFocus)

(can't test it as I don't currently have a working printer)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top