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
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