Solved

Printing group of files

Posted on 1998-05-28
6
166 Views
Last Modified: 2010-05-03
I have a group of files containing "canned" questions for each quote at work. I want to create a program that will print the files by possibly choosing an option button and hitting command button. I'm starting out by using one group of files and going to add option buttons etc. later.
I don't really know the best way to start. Do I need to open each file one at a time and then print the files by sending keystrokes to the application. I'm fairly new and am stuck as to a starting point. I would appreciate any suggestions. I have been able to send keystrokes to one of the files and get it to print, but there has got to be a better way.
Thanks for the help..
0
Comment
Question by:darrel
6 Comments
 
LVL 1

Expert Comment

by:web_crusher
ID: 1461976
is your files are ascii based - if not send me the type of file you would like to print
i'll send you the procedure!

0
 
LVL 18

Expert Comment

by:deighton
ID: 1461977
I'm sure we can help!  More infoe needed.

How did you create the files - are they in a text format i.e. viewable via Notepad for example.

Are you looking to retrieve text from the file and the dispaly it in a label or text box so the user can read and answer the question.

You can open text files in VB using

dim x as string

OPEN "quet.txt" for input as #1
LINE INPUT #1, x1      'inputs a line of text from the file
LINE INPUT #1,x2      'input next line

Text1.txt = x1                                'text box allowing multiple lines
Text1.txt = Text1.txt + vbcrlf + x2

close #1

THE above is a possible example of what I imagine you want to do


Look forward to hearing more
0
 

Author Comment

by:darrel
ID: 1461978
There are 4 WinWord files and 3 PowerPoint files. The WinWord files are just .doc and the power point are presentation files. If you could help me with the WinWord files, I can surely figure out the PowerPoint. Currently I must open all files print each and then close them.
Thanks for the help.
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 6

Accepted Solution

by:
clifABB earned 150 total points
ID: 1461979
To print your four word files, add a reference to Word (Project/References)
Then add this code (Replace Filename1.doc through Filename4.doc with the path\filnames you use):
  Dim wwdocs As New Word.Application
 
  wwdocs.Documents.Open "Filename1"
  wwdocs.PrintOut
  Do Until wwdocs.BackgroundPrintingStatus = 0
    DoEvents
  Loop
  wwdocs.Quit
  wwdocs.Documents.Open "Filename2"
  wwdocs.PrintOut
  Do Until wwdocs.BackgroundPrintingStatus = 0
    DoEvents
  Loop
  wwdocs.Quit
  wwdocs.Documents.Open "Filename3"
  wwdocs.PrintOut
  Do Until wwdocs.BackgroundPrintingStatus = 0
    DoEvents
  Loop
  wwdocs.Quit
  wwdocs.Documents.Open "Filename4"
  wwdocs.PrintOut
  Do Until wwdocs.BackgroundPrintingStatus = 0
    DoEvents
  Loop
  wwdocs.Quit

0
 
LVL 6

Expert Comment

by:clifABB
ID: 1461980
Just as an added note.  You might want to create a subroutine to print a file from Word, something like this:

Sub PrintDocFile(sFilename As String)
  Dim wwDocs As New Word.Application
 
  wwDocs.Documents.Open sFilename
  wwDocs.PrintOut
  Do Until wwDocs.BackgroundPrintingStatus = 0
    DoEvents
  Loop
  wwDocs.Quit
End Sub

And then you can call it passing the name of the file:
PrintDocFile "c:\Filename1.doc"
PrintDocFile "c:\Filename2.doc"
PrintDocFile "c:\Filename3.doc"
PrintDocFile "c:\Filename4.doc"

0
 

Author Comment

by:darrel
ID: 1461981
thanks for the help. I'll do the same for the powerpoint files.

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel Vlookup to move data back to source. 4 90
Copy a row 12 61
MS SQL store procedure to calculate and return result 6 57
MsgBox 4 59
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

786 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