Solved

Printing A text file

Posted on 2000-04-14
9
135 Views
Last Modified: 2010-05-02
On Command, I want to My program to print a Text file to my printer. (I have muliple printers on a network). How do I send my text file to one of these printers?
0
Comment
Question by:R_N_WARD
9 Comments
 

Author Comment

by:R_N_WARD
ID: 2717026
I need some help, any help, FAST!
0
 

Author Comment

by:R_N_WARD
ID: 2717078
I need some help, any help, FAST!
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2717103
Private Sub cmdPrint_Click()
Printer.Print Text1.Text
Printer.EndDoc
End Sub
0
 

Author Comment

by:R_N_WARD
ID: 2717117
AzraSound, I need to print A File like C:\Textfile.txt
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:R_N_WARD
ID: 2717121
AzraSound, I need to print A File like C:\Textfile.txt
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 35 total points
ID: 2717137
just load the file into a text box or a richtextbox.  richtextbox has its own load and print methods built in.

richtextbox.loadfile "filename and path"
richtextbox.SelPrint (Printer.hDC)
0
 

Author Comment

by:R_N_WARD
ID: 2717156
Thanks for the advice, AzraSound.
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2717168
Adda Common Dialog control to your project (CommonDialog1) and copy and paste the following in:

<----- Code Begin ----->

   Dim strPrint As String
   Open "c:\autoexec.bat" For Binary As #1
   strPrint = Space$(LOF(1) - 1)
   Get #1, , strPrint
   Close (1)
   
   CommonDialog1.CancelError = True
   On Error GoTo PrintCancel
   CommonDialog1.ShowPrinter
   Printer.Print (strPrint)
   Printer.EndDoc
   On Error Goto 0

PrintCancel:

<----- Code End ----->
0
 
LVL 7

Expert Comment

by:BarryTice
ID: 2717192
You've got two other ways (at least).

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
    ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
    ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Sub Command1_Click()

ShellExecute me.hwnd, "Print", "File.txt", "", "C:\Path\SubPath\", &H01

End Sub


' or

Public Sub Command2_Click()

Dim intFile as Integer
Dim strText as String

intFile = FreeFile
Open "C:\Path\SubPath\File.txt" For Input As #intFile
Do While Not EOF(intFile)
    Line Input #intFile, strText
    Printer.Print strText
Loop
Close #intFile
Printer.EndDoc

End Sub
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now