Link to home
Start Free TrialLog in
Avatar of RIAS
RIASFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Wordmerge

Hello,
I have a code for wordmerge but, the match case doesnt seem to work .
I have TO:  and To: to replace and it is not able to distinguish between the cases and replaces everthing .

                    If dtSQL.Rows(0)("Guestname").ToString Is DBNull.Value = False Then

                        With oDoc.Content.Find

                            .Forward = True
                            .Format = False
                            .MatchCase = True
                            .MatchWholeWord = True
                            .MatchWildcards = True
                            .MatchSoundsLike = True
                            .MatchAllWordForms = False
                            .Font.Bold = False
                            oDoc.Content.Find.Execute(FindText:="TO:",
                    ReplaceWith:="TO: " & dtSQL.Rows(0)("Guestname").ToString, Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll)
                        End With
                    End If

Open in new window

Avatar of Rgonzo1971
Rgonzo1971

Hi,

pls try

    With oDoc.Content.Find
        .Text = "to:"
        .Replacement.Text = "^& " & dtSQL.Rows(0)("Guestname").ToString
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
        .Execute(Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll)
    End With

Open in new window

Regards
Avatar of RIAS

ASKER

Cheers! will try and get back!
Avatar of RIAS

ASKER

wdFindContinue is not declared?
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RIAS

ASKER

Mate,

This code worked
 With oDoc.Content.Find
                            .Text = "To:"
                            .Replacement.Text = "^& " & dtSQL.Rows(0)("Guestname").ToString
                            .Forward = True
                            .Wrap = Microsoft.Office.Interop.Word.WdFindWrap.wdFindContinue
                            .Format = False
                            .MatchCase = False
                            .MatchWholeWord = False
                            .MatchWildcards = False
                            .MatchSoundsLike = False
                            .MatchAllWordForms = False
                            .Execute(Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll)


                        End With

Open in new window

Avatar of RIAS

ASKER

Cheers!.

Is there a way I can replace the text with lower case?
try by replacing ^& in the replacement text with to:
Avatar of RIAS

ASKER

Cheers mate!