Help!

Printing the contents of a textbox

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> User Forms RSS
Next:  How do you use MS Word to make up an Excel type w..  
Author Message
Roderick O'Regan
External


Since: Mar 30, 2005
Posts: 7



PostPosted: Fri Feb 16, 2007 6:28 pm    Post subject: Printing the contents of a textbox
Archived from groups: microsoft>public>word>vba>userforms (more info?)

Is there a way, please, to print the text contents of a large userform
textbox?

To explain: A template has a userform which gets data from a database
(an Excel file). The userform has a combo box showing the title from
one cell. The long and expanded contents of the adjoing cell then
displays in the large userform textbox.

No problems up to this stage. However, the client has now asked me for
the facility to directly print out the contents of that large textbox
in case the user wants to take a more considered review of the text.
The user would press a "Print it" button on the userform.

Can this be done?

Checking the Print commands in VBA seems to display examples of only
printing the document created from the template.

Roderick
Back to top
Greg Maxey
External


Since: Feb 05, 2007
Posts: 103



PostPosted: Fri Feb 16, 2007 6:28 pm    Post subject: Re: Printing the contents of a textbox [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Feb 16, 8:28 am, Roderick O'Regan
wrote:
> Is there a way, please, to print the text contents of a large userform
> textbox?
>
> To explain: A template has a userform which gets data from a database
> (an Excel file). The userform has a combo box showing the title from
> one cell. The long and expanded contents of the adjoing cell then
> displays in the large userform textbox.
>
> No problems up to this stage. However, the client has now asked me for
> the facility to directly print out the contents of that large textbox
> in case the user wants to take a more considered review of the text.
> The user would press a "Print it" button on the userform.
>
> Can this be done?
>
> Checking the Print commands in VBA seems to display examples of only
> printing the document created from the template.
>
> Roderick

Roderick,

The following code is crude, but shows that it could be done:

Private Sub PrintButton_Click()
Dim oScratchPad As Word.Document
Set oScratchPad = Documents.Add
oScratchPad.Range.Text = Me.TextBox1.Text
oScratchPad.PrintOut
oScratchPad.Close wdDoNotSaveChanges
End Sub

It simply creates a new document, sticks in the textbox text, prints
it, and closes.

To gussy it up some, you might create a template that opens with some
boilerplate text, etc and set oScratchpad to a new document based on
that template and stick the textbox text in the proper place.
Back to top
Roderick O'Regan
External


Since: Mar 30, 2005
Posts: 7



PostPosted: Sat Feb 17, 2007 2:18 am    Post subject: Re: Printing the contents of a textbox [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Greg.

Thank you for the suggested code. It does exactly what I needed but
could not figure out how to do it.

However, the client has just thrown me a very nasty curve ball which
stands this whole topic on its head. I'm going to have to think a
little what it is I want to do and then create a new thread for
discussion and guidance.

Thanks again.

Roderick

On 16 Feb 2007 05:51:07 -0800, "Greg Maxey" wrote:

>On Feb 16, 8:28 am, Roderick O'Regan
>wrote:
>> Is there a way, please, to print the text contents of a large userform
>> textbox?
>>
>> To explain: A template has a userform which gets data from a database
>> (an Excel file). The userform has a combo box showing the title from
>> one cell. The long and expanded contents of the adjoing cell then
>> displays in the large userform textbox.
>>
>> No problems up to this stage. However, the client has now asked me for
>> the facility to directly print out the contents of that large textbox
>> in case the user wants to take a more considered review of the text.
>> The user would press a "Print it" button on the userform.
>>
>> Can this be done?
>>
>> Checking the Print commands in VBA seems to display examples of only
>> printing the document created from the template.
>>
>> Roderick
>
>Roderick,
>
>The following code is crude, but shows that it could be done:
>
>Private Sub PrintButton_Click()
>Dim oScratchPad As Word.Document
>Set oScratchPad = Documents.Add
>oScratchPad.Range.Text = Me.TextBox1.Text
>oScratchPad.PrintOut
>oScratchPad.Close wdDoNotSaveChanges
>End Sub
>
>It simply creates a new document, sticks in the textbox text, prints
>it, and closes.
>
>To gussy it up some, you might create a template that opens with some
>boilerplate text, etc and set oScratchpad to a new document based on
>that template and stick the textbox text in the proper place.
>
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> User Forms All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum