Group:  Microsoft Word ยป microsoft.public.word.vba.userforms
Thread: Formatting Text Input From Dialog Box

Formatting Text Input From Dialog Box
J At Work 5/30/2007 6:00:01 PM
I'm revising and consolidating a number of business letters. Most just use
form fields and drop-down menus, but for some of the more complex letters I
have been writing simple macros that run upon selection from a drop-down, ask
the user for a few bits of data, and spit out the relevant sentence or
paragraph.

The problem is that while the form field text can be set up to autoformat, I
haven't been able to figure out how to do the same for the dialog box input.
I just need to convert dialog box inputs in the same manner as form fields,
e.g., 010107 into January 1, 2007, 1234567 into 1-2345-67. These letters will
be used by novice users that are going to get confused if the data formatting
works in one place but doesn't in another.

I am a newbie to VBA but not to coding, and I just can't find any info on
how to forcibly format the dialog box variables so that they "print" in the
correct format. Please help!
Thanks,
J
Re: Formatting Text Input From Dialog Box
Cindy M. <C.Meister-C[ at ]hispeed.ch> 6/5/2007 5:14:34 PM
Hi =?Utf-8?B?SiBBdCBXb3Jr?=,

[Quoted Text]
> I'm revising and consolidating a number of business letters. Most just use
> form fields and drop-down menus, but for some of the more complex letters I
> have been writing simple macros that run upon selection from a drop-down, ask
> the user for a few bits of data, and spit out the relevant sentence or
> paragraph.
>
> The problem is that while the form field text can be set up to autoformat, I
> haven't been able to figure out how to do the same for the dialog box input.
> I just need to convert dialog box inputs in the same manner as form fields,
> e.g., 010107 into January 1, 2007, 1234567 into 1-2345-67. These letters will
> be used by novice users that are going to get confused if the data formatting
> works in one place but doesn't in another.
>
> I am a newbie to VBA but not to coding, and I just can't find any info on
> how to forcibly format the dialog box variables so that they "print" in the
> correct format.
>
You want to convert what the user types, so that it appears formatted while
still in the dialog box? Or just when inserting back into the form document?

The latter will certainly be simpler. For the former you'd need to use one of
the events provided by a textbox control, and getting it "just right" can be
tricky. Best is to use the Exit event (analog to a form field) so that the
formatting code executes when the user moves to the next field.

In either case, you can probably achieve a lot using the Format command. There's
quite a bit in the VBA help, to get you started.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)

Home | Search | Terms | Imprint
Newsgroups Reader