Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

How can I print a preformated file directly to printer?

Total Hit ( 2687)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Step-By-Step Example

1. On a Microsoft NT 4.0 system, add a printer with a name that contains a space.
2. Create a text file in the C:\ folder, for example, test.txt.
3. Start a new Standard EXE project in Visual Basic. Form1 is created by default.
4. From the Project menu, select References, check Microsoft Scripting Runtime, and click OK.
5. Add a CommandButton to the form.
6. Paste the following code in the code window of Form1:

Click here to copy the following block
Private Sub Command1_Click()
  Dim FSO  'As FileSystemObject
  Set FSO = CreateObject("Scripting.FileSystemObject")

  ' To print on WinNT
  FSO.CopyFile "C:\boot.ini", Printer.DeviceName

  ' If the devicename is like this: \\servername\HPLaser400, the file prints
  ' If the devicename is \\servername\HP Laser 400, the above mentioned
  ' run-time error occurs

  ' To print on Win9x
  ' FSO.CopyFile "C:\test.txt",Printer.Port
End Sub

7. Press the F5 key to run the project, and then click on the CommandButton.
8. The file test.txt is printed if the DeviceName is one word without spaces.
9. Alternatively, you can use APIs to bypass the printer driver and send data to the printer. This is documented in article Q154078 listed below in the "References" section.


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.