Add a \*charformat switch to the Docproperty field and format the D of
Docproperty as italic.

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Hi All
>
[quoted text clipped - 38 lines]
>
> Debra
Debra Farnham - 19 Jan 2005 02:28 GMT
Thanks for your response Doug but will that format only a few of the words
that will be inserted or all of them?
TIA
Debra
> Add a \*charformat switch to the Docproperty field and format the D of
> Docproperty as italic.
[quoted text clipped - 41 lines]
> >
> > Debra
Debra Farnham - 19 Jan 2005 04:07 GMT
I think I'm almost there:
Public Sub test()
Dim SearchString, SearchChar, MyFirstHyphen, MySecondHyphen, Phrase, myrange
SearchString = ActiveDocument.CustomDocumentProperties("Offence") ' String
to search in.
SearchChar = "-"
'find first hyphen
MyFirstHyphen = InStr(4, SearchString, SearchChar, 1) + 1
'find second hyphen
MySecondHyphen = InStr(MyFirstHyphen, SearchString, SearchChar, 1) -
MyFirstHyphen - 1
Phrase = Mid(SearchString, MyFirstHyphen, MySecondHyphen) 'This gets me the
string I want to italicize
***NEED HELP HERE - I'M STUCK ON TRYING TO GET THE DARN PHRASE
ITALICIZED****
Set myrange = Phrase
myrange.Italic = True
***********************
End Sub
Thank you to anyone who might be able to help!
Debra
> Add a \*charformat switch to the Docproperty field and format the D of
> Docproperty as italic.
[quoted text clipped - 41 lines]
> >
> > Debra
Debra Farnham - 19 Jan 2005 13:42 GMT
Not very elegant but this is what I came up with. Is there a better way?
Dim SearchString, SearchChar, MyFirstHyphen, MySecondHyphen, Phrase
SearchChar = "-" ' Search for "-".
SearchString = ActiveDocument.CustomDocumentProperties("Offence") ' String
to search in.
'find first hyphen
MyFirstHyphen = InStr(4, SearchString, SearchChar, 1) + 1
'find second hyphen
MySecondHyphen = InStr(MyFirstHyphen, SearchString, SearchChar, 1) -
MyFirstHyphen - 1
Phrase = Mid(SearchString, MyFirstHyphen, MySecondHyphen)
'Italicize Text
Selection.Find.Replacement.Font.Italic = True
With Selection.Find
.Text = Phrase
.Replacement.Text = Phrase
.Forward = True
.Wrap = wdFindContinue
.Format = True
End With
Selection.Find.Execute
With Selection
If .Find.Forward = True Then
.Collapse direction:=wdCollapseStart
Else
.Collapse direction:=wdCollapseEnd
End If
.Find.Execute Replace:=wdReplaceOne
If .Find.Forward = True Then
.Collapse direction:=wdCollapseEnd
Else
.Collapse direction:=wdCollapseStart
End If
.Find.Execute
End With
Debra
> Add a \*charformat switch to the Docproperty field and format the D of
> Docproperty as italic.
[quoted text clipped - 41 lines]
> >
> > Debra