There are a variety of ways to get the first word of a string or indeed any
part of any string.
One of the more basic ways is to determine where the first word ends in the
string and to take everything before that point. (You can also split an array
but it might be best if you're starting out to get to grips with basic string
manipulation before advancing to arrays IMHO.)
Dim lngNum As Long
Dim strName As String
Dim strFirstName As String
'Get position of first space in Name string
lngNum = InStr(1, strName, " ")
'Subtract 1 from lngNum to get length
'of first word, take everyting to the left
'up to that point
strFirstName = Left(strName, lngNum - 1)
You can use strings to name documents:
docDoc.SaveAs "C:\" & strFirstName & ".doc"
Be careful though -- you may have more than one applicant with the same
first name so you'd need to differentiate the doc names. You'd need to check
the doc name first to see if it exists, and if it does, try new names until
you find one that isn't already taken. The following code creates a variable
x to act as a counter that adds a number after the person's first name if a
file already exists using that first name.
Dim x As Long
'start at 2 to create new docs named
'"Sri.doc" then "Sri2.doc", "Sri3.doc" etc
x = 2
'Add x to the first name for so long as
'documents exist
Do While Dir("c:\" & strFirstName & ".doc") <> ""
strFirstName = strFirstName & x
Loop
docDoc.SaveAs "c:\" & strFirstName & ".doc"
> Can you please help me in identifying the first word in the Sring text_1
> assuming that text_1 has one or more than one word.
[quoted text clipped - 3 lines]
>
> Thanks in advance
Sridhar Pentlavalli - 23 Mar 2005 16:12 GMT
Dear Chuck,
With your great help I completed my project successfully. All the credit
that my leader gave to me actually goes to you. Now Chuck is the name known
in our project as an MS-OFFICE SPECIALIST.
Thank you very much
Sridhar P
Chuck - 23 Mar 2005 16:19 GMT
You're too kind. I blush. ;-)
> Dear Chuck,
>
[quoted text clipped - 4 lines]
> Thank you very much
> Sridhar P