Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

Change Case in Text Box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 13 Jan 2005 08:05 GMT
I have this very simple code to populate the third text box (tbx3) in a form
with the information the user typed in the first text box (tbx1).  However, I
want the value in tbx3 to be Title Case.  

I can't get
Range.Case = wdTitleWord
to work because I can't (or don't know how to) convert the value in tbx1 to
a range or selection.  Is there a way?

Private Sub tbx1_AfterUpdate()
   tbx3.Text = tbx1.Value
End Sub

Thanks!
Jonathan West - 13 Jan 2005 10:36 GMT
You'll have to do this by hand, writing your own string manipulation
routine. If you want title case, the following should work, provided you are
using Word 2000 or later. Put the following into a module somewhere

Function TitleCase(strIn As String)
Dim vWords As Variant
Dim i As Long
vWords = Split(strIn, " ")
For i = 0 To UBound(vWords)
 Mid(vWords(i), 1) = UCase(Left$(vWords(i), 1))
Next i
TitleCase = Join(vWords, " ")
End Function

then you can use the function like this

Private Sub tbx1_AfterUpdate()
  tbx3.Text = TitleCase(tbx1.Value)
End Sub

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

>I have this very simple code to populate the third text box (tbx3) in a
>form
[quoted text clipped - 13 lines]
>
> Thanks!
Andrew - 14 Jan 2005 02:33 GMT
Very nice.  I'll try it.

Thanks!

> You'll have to do this by hand, writing your own string manipulation
> routine. If you want title case, the following should work, provided you are
[quoted text clipped - 33 lines]
> >
> > Thanks!
Mark Tangard - 17 Jan 2005 07:50 GMT
Hi Jonathan (and Andrew),

Couldn't he use the string converter function?

    StrConv(strIn, vbProperCase)

--
Mark Tangard
"Life is nothing if you're not obsessed." --John Waters

> You'll have to do this by hand, writing your own string manipulation
> routine. If you want title case, the following should work, provided you
[quoted text clipped - 16 lines]
> End Sub
>
Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup

> I have this very simple code to populate the third text box (tbx3) in a form
> with the information the user typed in the first text box (tbx1). However, I
[quoted text clipped - 10 lines]
>
> Thanks!

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.