ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing the contents of a text control on a user form (https://www.excelbanter.com/excel-programming/362223-printing-contents-text-control-user-form.html)

Chaplain Doug

Printing the contents of a text control on a user form
 
Excel 2003. I have a user form called "ProcessStatus" that has a text box
called "ProcStat" which is populated with information as a process completes.
I have placed a "Print" button control on the form that I want to use to
print the contents of the text box. What code would I use to print the text
box contents?

ProcessStatus.Print does not work as it prints the whole form. The text box
has a verical scroll and thus all text is not printed.

Thanks for any help you may give. God bless.

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

Tom Ogilvy

Printing the contents of a text control on a user form
 
from an Old post:

Sub Macro5()
Dim ctrl as Long
Dim tmpstr as String
Open "LPT1:" For Output As #1
Print #1, "[Start of Printing Test]"
For ctrl = 1 To 10
tmpstr = "Printing ine " + Str(ctrl)
Print #1, tmpstr
Next
tmpstr = "[End of printing test]" + Chr(12)
Print #1, tmpstr
Close #1
End Sub


To a Network printer


First, I went to the immediate window in the VBE to query the activeprinter
string


? activePrinter
\\ARDAPS01\1D343E on Ne02:

then I used the first part in the below code:

Sub Macro5()
Dim ctrl As Long
Dim tmpstr As String
Open "\\ARDAPS01\1D343E" For Output As #1
Print #1, "[Start of Printing Test]"
For ctrl = 1 To 10
tmpstr = "Printing Line " + Str(ctrl)
Print #1, tmpstr
Next
tmpstr = "[End of printing test]" + Chr(12)
Print #1, tmpstr
Close #1
End Sub

Worked for me.

Regards,
Tom Ogilvy
------------------------------------
So modify the code above to use the textstring in your text box

tmpstr = textbox2.Text

as an example.

--
Regards,
Tom Ogilvy


"Chaplain Doug" wrote:

Excel 2003. I have a user form called "ProcessStatus" that has a text box
called "ProcStat" which is populated with information as a process completes.
I have placed a "Print" button control on the form that I want to use to
print the contents of the text box. What code would I use to print the text
box contents?

ProcessStatus.Print does not work as it prints the whole form. The text box
has a verical scroll and thus all text is not printed.

Thanks for any help you may give. God bless.

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


Chaplain Doug

Printing the contents of a text control on a user form
 
Dear Tom:

Thank you for replying. However, when I try your code the "LPT1:" just goes
into a bit bucket somewhere, as I do not have anything connected to LPT1:,
but rather use a network printer.

Any other ideas? Thanks.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


"Tom Ogilvy" wrote:

from an Old post:

Sub Macro5()
Dim ctrl as Long
Dim tmpstr as String
Open "LPT1:" For Output As #1
Print #1, "[Start of Printing Test]"
For ctrl = 1 To 10
tmpstr = "Printing ine " + Str(ctrl)
Print #1, tmpstr
Next
tmpstr = "[End of printing test]" + Chr(12)
Print #1, tmpstr
Close #1
End Sub


To a Network printer


First, I went to the immediate window in the VBE to query the activeprinter
string


? activePrinter
\\ARDAPS01\1D343E on Ne02:

then I used the first part in the below code:

Sub Macro5()
Dim ctrl As Long
Dim tmpstr As String
Open "\\ARDAPS01\1D343E" For Output As #1
Print #1, "[Start of Printing Test]"
For ctrl = 1 To 10
tmpstr = "Printing Line " + Str(ctrl)
Print #1, tmpstr
Next
tmpstr = "[End of printing test]" + Chr(12)
Print #1, tmpstr
Close #1
End Sub

Worked for me.

Regards,
Tom Ogilvy
------------------------------------
So modify the code above to use the textstring in your text box

tmpstr = textbox2.Text

as an example.

--
Regards,
Tom Ogilvy


"Chaplain Doug" wrote:

Excel 2003. I have a user form called "ProcessStatus" that has a text box
called "ProcStat" which is populated with information as a process completes.
I have placed a "Print" button control on the form that I want to use to
print the contents of the text box. What code would I use to print the text
box contents?

ProcessStatus.Print does not work as it prints the whole form. The text box
has a verical scroll and thus all text is not printed.

Thanks for any help you may give. God bless.

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


Chaplain Doug

Printing the contents of a text control on a user form
 
Never mind Tom. I did not read down far enough in your first reply. Thanks.
--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org


"Tom Ogilvy" wrote:

from an Old post:

Sub Macro5()
Dim ctrl as Long
Dim tmpstr as String
Open "LPT1:" For Output As #1
Print #1, "[Start of Printing Test]"
For ctrl = 1 To 10
tmpstr = "Printing ine " + Str(ctrl)
Print #1, tmpstr
Next
tmpstr = "[End of printing test]" + Chr(12)
Print #1, tmpstr
Close #1
End Sub


To a Network printer


First, I went to the immediate window in the VBE to query the activeprinter
string


? activePrinter
\\ARDAPS01\1D343E on Ne02:

then I used the first part in the below code:

Sub Macro5()
Dim ctrl As Long
Dim tmpstr As String
Open "\\ARDAPS01\1D343E" For Output As #1
Print #1, "[Start of Printing Test]"
For ctrl = 1 To 10
tmpstr = "Printing Line " + Str(ctrl)
Print #1, tmpstr
Next
tmpstr = "[End of printing test]" + Chr(12)
Print #1, tmpstr
Close #1
End Sub

Worked for me.

Regards,
Tom Ogilvy
------------------------------------
So modify the code above to use the textstring in your text box

tmpstr = textbox2.Text

as an example.

--
Regards,
Tom Ogilvy


"Chaplain Doug" wrote:

Excel 2003. I have a user form called "ProcessStatus" that has a text box
called "ProcStat" which is populated with information as a process completes.
I have placed a "Print" button control on the form that I want to use to
print the contents of the text box. What code would I use to print the text
box contents?

ProcessStatus.Print does not work as it prints the whole form. The text box
has a verical scroll and thus all text is not printed.

Thanks for any help you may give. God bless.

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



All times are GMT +1. The time now is 05:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com