(Msg. 1) Posted: Fri Feb 16, 2007 1: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.
(Msg. 2) Posted: Fri Feb 16, 2007 1: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 <r... DeleteThis @removethis.theoregans.com>
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.
(Msg. 3) Posted: Fri Feb 16, 2007 9:18 pm
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" <gmaxey RemoveThis @gmail.com> wrote:
>On Feb 16, 8:28 am, Roderick O'Regan <r... RemoveThis @removethis.theoregans.com>
>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.
>
All times are: Eastern Time (US & Canada) (change)
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