Use wdTitleWord on .Replacement.Text

G

GolferGuy

wdTitleWord seems to only want to work with a Range object. I have
replacement text that I'm getting from an Access database using VBA that
needs to have each word capitalized depending on it's place within the Word
document. I thought the time to do it would be before doing the Find/Replace
operation but I do not know of any way to use the wdTitleWord with
Selection.Find.Replacement.Text.
/code: code runs within MS Access. "wd" is Word.Application,
"VarFound" is the Access field name referenced in the Word
document
Dim VarFound As String
VarFound = wd.Selection.Range
wd.ActiveDocument.Range.Select
With wd.Selection.Find
.ClearFormatting
.Text = "\{mfld" & VarFound & "\}"
.Replacement.Text = ""
.Replacement.Text = DLookup(VarFound, "tblDocumentVariables",
selCrition)
'Selection.Range.Case = wdTitleWord '<--This works, but need it to work
below
wd.Selection.Range.Find.Replacement.Text = wdTitleWord '<-- Does not
work
.Execute Replace:=wdReplaceAll
End With
 
S

Shasur

Hi

When you do a normal replacement, Word automatically takes the casing of the
'Found' word. If the found word has intial caps, the replace word will also
be capitalized accordingly

Cheers
Shasur
 

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