Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 300
Default Printing Text Files from VBA

I'm working on a large application that now calls APL through an ActiveX
server. APL manages a bunch of databases, does calculations, formats
reports, and prints them to the default printer. All interface with the
user is already in Excel/VBA. I'm working to eliminate the APL. Access can
take over the APL component files. VBA, of course, can handle the
calculations, and in some cases more easily, using the built in BetaDist
and GammaLn functions.

With help here I'm now reading and writing small text files, which APL did
before. Next along this line is to print them. In APL I have a rather
sophisticated formatting routine that the APL people wrote for me. But to
start I'd be happy in just sending the text file to the printer. Maybe
someday I can replicate the formatting that APL does, especially the fit to
page capability.

Don <donwiss at panix.com.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Printing Text Files from VBA

Have you tried automating Word using VBA from Excel?

http://word.mvps.org/FAQs/index.htm
When you get to the site, choose the "Office Interdevelopment" tab and start
with the link to control Word from Excel.

Steve


"Don Wiss" wrote in message
...
I'm working on a large application that now calls APL through an ActiveX
server. APL manages a bunch of databases, does calculations, formats
reports, and prints them to the default printer. All interface with the
user is already in Excel/VBA. I'm working to eliminate the APL. Access can
take over the APL component files. VBA, of course, can handle the
calculations, and in some cases more easily, using the built in BetaDist
and GammaLn functions.

With help here I'm now reading and writing small text files, which APL did
before. Next along this line is to print them. In APL I have a rather
sophisticated formatting routine that the APL people wrote for me. But to
start I'd be happy in just sending the text file to the printer. Maybe
someday I can replicate the formatting that APL does, especially the fit
to
page capability.

Don <donwiss at panix.com.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Printing Text Files from VBA

the easiest would be to open the file in excel and print it from there. Or
you could use the low level fileio and parse it into excel, then print it
from excel

Another would be to open it in word and print it from there

You can wite it directly to the printer a line at a time or perhaps more
than a line at a time, same as you read it in.



--
Regards,
Tom Ogilvy


"Don Wiss" wrote in message
...
I'm working on a large application that now calls APL through an ActiveX
server. APL manages a bunch of databases, does calculations, formats
reports, and prints them to the default printer. All interface with the
user is already in Excel/VBA. I'm working to eliminate the APL. Access can
take over the APL component files. VBA, of course, can handle the
calculations, and in some cases more easily, using the built in BetaDist
and GammaLn functions.

With help here I'm now reading and writing small text files, which APL did
before. Next along this line is to print them. In APL I have a rather
sophisticated formatting routine that the APL people wrote for me. But to
start I'd be happy in just sending the text file to the printer. Maybe
someday I can replicate the formatting that APL does, especially the fit

to
page capability.

Don <donwiss at panix.com.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 300
Default Printing Text Files from VBA

On Sat, 8 Jan 2005 14:50:10 -0500, Tom Ogilvy wrote:

the easiest would be to open the file in excel and print it from there. Or
you could use the low level fileio and parse it into excel, then print it
from excel

Another would be to open it in word and print it from there

You can wite it directly to the printer a line at a time or perhaps more
than a line at a time, same as you read it in.


Actually I miswrote my request. The text I want to print is already in
Excel as strings. For now I used Excel to print. It is a bit slow the way I
did it. I'm sure writing it directly to the printer would be faster, but at
least the Excel way lets me play with formatting. I'll probably start
enhancing the below. At least change the format based on the ending value
of j.

Sub PrintText(S As String)
' arg: CR/LF delimited text string
' reads: global ViewerType

Dim SheetName As String
Dim i As Integer, j As Integer, T As String

Application.StatusBar = "Printing..."
SheetName = ActiveSheet.Name

' create hidden sheet
Application.ScreenUpdating = False
Sheets.Add
Range("A:A").ColumnWidth = 100
Columns("A:A").WrapText = True
Cells.Font.Name = "Courier New"

' place text on sheet
For i = 1 To Len(S)
If Mid(S, i, 1) < Chr(13) Then
T = T & Mid(S, i, 1)
Else
j = j + 1
Cells(j, 1).Value = T
T = ""
i = i + 1
End If
Next i

' print
With ActiveSheet
With .PageSetup
If ViewerType = 1 Then
.CenterHeader = "WC Parameter History"
ElseIf ViewerType = 2 Then
.CenterHeader = "Sheet Instructions for: " & SheetName
End If
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
.PrintOut

' delete temp sheet
Application.DisplayAlerts = False
.Delete
Application.DisplayAlerts = True
End With

' put people back where they were
Sheets(SheetName).Select
Application.StatusBar = False

End Sub

Don <donwiss at panix.com.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing pdf files from Excel 2007 Bern Notice[_2_] Excel Discussion (Misc queries) 2 January 4th 09 05:43 PM
Excel (xls) files spontaneously converting to text files Be-jamin Excel Discussion (Misc queries) 0 November 18th 08 05:31 PM
Printing Multiple Files bw Excel Discussion (Misc queries) 3 November 5th 07 06:09 PM
Excel printing to separate files Glenn Allan Setting up and Configuration of Excel 0 June 15th 07 12:30 PM
printing sheets in different files Jean-Paul De Winter Excel Programming 6 November 1st 04 04:09 PM


All times are GMT +1. The time now is 10:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"