Formatting of data in a field

M

M.L.Srinivas

Hi,

I'm having a peculiar problem when working with the data
(result) of a field in the document.
I'm using customdocumentproperties and these were inserted
as fields in the document.

When the user gives input the fields will get updated. The
problem is with formatting.
I want the data to be displyed in intial caps irrespective
of the format of the data the user had given.
For this I used:
{DOCPROPERTY FirstName \* Caps \* MERGEFORMAT}
Coz, to my knowledge \* Caps displays the data in intial
caps. This is working fine. Now, the problem is with
"George III" sort of names. It is being displayed
as "George Iii".
Similar is the case with "O'Connor" and "McKinney".

How to overcome this? To do this I adopted the logic of
changing the data displayed to my
required format.
Part of my code is:
For Each oStory In DocName.StoryRanges

If oStory.StoryType <>
wdFirstPageHeaderStory Then
oStory.Fields.Update
For Each w In oStory.Fields
cd = Trim(w.code)

PropName = Split(cd, " ")
(1)
If PropName = "FirstName"
Then
Set MyRange = w.Result
MyRange.Text = fname
Set MyRange = Nothing
ElseIf PropName
= "LastName" Then
Set MyRange = w.Result
MyRange.Text = lname
Set MyRange = Nothing
End If

Next
End If
If oStory.StoryType < wdMainTextStory Then
While Not (oStory.NextStoryRange Is
Nothing)
Set oStory = oStory.NextStoryRange
If oStory.StoryType <>
wdFirstPageHeaderStory Then

oStory.Fields.Update
End If
Wend
End If
Next oStory
Set MyRange = Nothing
Set w = Nothing
Set oStory = Nothing

Fname and Lname will have data in required format. This is
also working fine, but when we close
and open the document again the text is again changing
back to "George Iii". And interestingly this
is happening for the fields in header and footer only but
not for fields in general text, they are
retaining the new format,"George III".

Please help. I'm unable to identify the problem and also I
have no solution with me.


Thanks

M.L.Srinivas
 
P

Peter Hewett

Hi M.L.Srinivas

Since the data source of your fields is a CustomDocumentProperty why not just
update the CustomDocumentProperty and let the field display what's really
there?

HTH + Cheers - Peter
 
M

M.L.Srinivas

Peter thanks for your time.

Even if we update the customdocumentproperty, it will
display the data in "George Iii" fashion as the field code
is
{DOCPROPERTY FirstName \* Caps \* MERGEFORMAT}
Coz, \* Caps displays data in intial caps.

any more suggestions?


M.L.Srinivas
-----Original Message-----
Hi M.L.Srinivas

Since the data source of your fields is a
CustomDocumentProperty why not just
 
P

Peter Hewett

Hi M.L.Srinivas

Not if you remove "\* Caps" from the field.

HTH + Cheers - Peter
 
C

Charles Kenyon

Remove the \* MERGEFORMAT as well!
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
M

M.L.Srinivas

Hi,

Thanks for your time Mr. Kenyon and Mr. Peter.

I'm afraid I cann't remove \* Caps and MERGEFORMAT.

Coz, 'caps' defines the format in which the data is to displayed.
Similarly I use 'upper' also according to the requirement. This helps
me to format the data approp., irrespective of the format of the use
input. This is very important.

My problem is only with peculiar names like George III, D'Souza,
McKinney etc.
Can you suggest any function which maintains this format?


Thanks
M.L.Srinivas
 
P

Peter Hewett

Hi M.L.Srinivas

There is no such function. You'll have to write (or maybe Google) you own.
This is complex in that there are a huge number of names with peculiar
capitalisation. The only way of doing this is using a database and a lookup
function.

Since "\*Caps" incorrectly capitalises names why bother with it????? Even if
you correct the name in your CustomDocumentProperty "\*Caps" is going to force
it to display incorrectly - yes?!

HTH + Cheers - Peter


(e-mail address removed) (M.L.Srinivas), said:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top