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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|