View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default How to Print a File or Control

Test this chaplain doug

Sub abc()
Dim PrinterName As String, I As Integer
s = "0123456789012345678901234567890123456789"
I = InStr(Application.ActivePrinter, " on ")
PrinterName = Mid(Application.ActivePrinter, 1, I - 1)
Open PrinterName For Output As #1
Print #1, s & s
Close #1

End Sub

this went all the way across the paper - if it does it for you, you may have
to take out the CHR(10)'s in your text box and place them in more appropriate
places in your text string.

--
Regards,
Tom Ogilvy



"Chaplain Doug" wrote:

Excel 2003. FIRST, I want to just be able to print (to my default printer)
the contents of a text control on a user form. I was given the following
code, but the printout is funky (margins are super narrow).

Dim PrinterName As String, I As Integer
I = InStr(Application.ActivePrinter, " on ")
PrinterName = Mid(Application.ActivePrinter, 1, I - 1)
Open PrinterName For Output As #1
Print #1, ProcessStatus.ProcStat.Text
Close #1

IS THERE A BETTER WAY TO ACCOMPLISH THIS?

SECOND, How does one print out an external file from Excel VBA code.
Suppose for instance that I want to print out file "Test.txt." How would I
program that? Thanks for the help and God bless.

--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org