A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Page Layout
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

UserForm data manipulation - trailing spaces and dimming/summing textbox fields



 
 
Thread Tools Display Modes
  #1  
Old October 14th, 2009, 11:10 PM posted to microsoft.public.word.pagelayout
Congenital Kano
external usenet poster
 
Posts: 5
Default UserForm data manipulation - trailing spaces and dimming/summing textbox fields

I've successfully created a template with a UserForm that prompts for data and merges this (via bookmarks) with the template text. Just a couple of questions remain, and Help isn't all that helpful.

In Word 2003 (creating a form letter where addressee info and two numbers are entered in UserForm):

1. The textbox text, when embedded in the doc text via bookmark, seems to always include a trailing space (i.e., "Name_"). Is there a way to trim this space? In salutation line of letter I end up with "Dear Mrs. Jones_:" instead of "Dear Mrs. Jones:" (underscore represents space here).

2. I need to add the numerical contents of one textbox with a constant value, which is hard-coded into template. Scratching my head trying to figure out how I can set the properties of the textbox entry (ideally to monetary nnn.nn format) and then add constant and print sum linked to another bookmark. Suggestions?

Thanks in advance.
  #2  
Old October 15th, 2009, 08:06 AM posted to microsoft.public.word.pagelayout
Doug Robbins - Word MVP
external usenet poster
 
Posts: 8,239
Default UserForm data manipulation - trailing spaces and dimming/summing textbox fields

Instead of using bookmarks, insert { DOCVARIABLE varName } fields where you want the data to appear

Then in your userfrom code, use

With ActiveDocument
.Variables("varAddressee").Value = txtAddressee.Text
' etc
.Variables("varAmount").Value = Format((nnn.nn + Val(txtAmount.Text)), "$#,###,00")
.Range.Fields.Update

where nnn.nn is the constant value that you want added to the number entered into the textbox.

Alternatively, you could do the addition and formatting with a field construction { = (nnn.nn + { DOCVARIABLE varAmount }) \# ,#.00 }

You must use Ctrl+F9 to insert each pair of field delimiters { }

--
Hope this helps

Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to avail yourself of my services on a paid, professional basis.

"Congenital Kano" wrote in message ...
I've successfully created a template with a UserForm that prompts for data and merges this (via bookmarks) with the template text. Just a couple of questions remain, and Help isn't all that helpful.

In Word 2003 (creating a form letter where addressee info and two numbers are entered in UserForm):

1. The textbox text, when embedded in the doc text via bookmark, seems to always include a trailing space (i.e., "Name_"). Is there a way to trim this space? In salutation line of letter I end up with "Dear Mrs. Jones_:" instead of "Dear Mrs. Jones:" (underscore represents space here).

2. I need to add the numerical contents of one textbox with a constant value, which is hard-coded into template. Scratching my head trying to figure out how I can set the properties of the textbox entry (ideally to monetary nnn.nn format) and then add constant and print sum linked to another bookmark. Suggestions?

Thanks in advance.
  #3  
Old October 15th, 2009, 08:57 PM posted to microsoft.public.word.pagelayout
Congenital Kano
external usenet poster
 
Posts: 5
Default UserForm data manipulation - trailing spaces and dimming/summing textbox fields

Thanks! Got it worked out.
"Doug Robbins - Word MVP" wrote in message ...
Instead of using bookmarks, insert { DOCVARIABLE varName } fields where you want the data to appear

Then in your userfrom code, use

With ActiveDocument
.Variables("varAddressee").Value = txtAddressee.Text
' etc
.Variables("varAmount").Value = Format((nnn.nn + Val(txtAmount.Text)), "$#,###,00")
.Range.Fields.Update

where nnn.nn is the constant value that you want added to the number entered into the textbox.

Alternatively, you could do the addition and formatting with a field construction { = (nnn.nn + { DOCVARIABLE varAmount }) \# ,#.00 }

You must use Ctrl+F9 to insert each pair of field delimiters { }

--
Hope this helps

Doug Robbins - Word MVP
Please reply only to the newsgroups unless you wish to avail yourself of my services on a paid, professional basis.

"Congenital Kano" wrote in message ...
I've successfully created a template with a UserForm that prompts for data and merges this (via bookmarks) with the template text. Just a couple of questions remain, and Help isn't all that helpful.

In Word 2003 (creating a form letter where addressee info and two numbers are entered in UserForm):

1. The textbox text, when embedded in the doc text via bookmark, seems to always include a trailing space (i.e., "Name_"). Is there a way to trim this space? In salutation line of letter I end up with "Dear Mrs. Jones_:" instead of "Dear Mrs. Jones:" (underscore represents space here).

2. I need to add the numerical contents of one textbox with a constant value, which is hard-coded into template. Scratching my head trying to figure out how I can set the properties of the textbox entry (ideally to monetary nnn.nn format) and then add constant and print sum linked to another bookmark. Suggestions?

Thanks in advance.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:52 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.