Solved

Wordmerge

Posted on 2016-09-26
8
47 Views
Last Modified: 2016-09-26
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

0
Comment
Question by:RIAS
  • 5
  • 3
8 Comments
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 41815826
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
0
 

Author Comment

by:RIAS
ID: 41815830
Cheers! will try and get back!
0
 

Author Comment

by:RIAS
ID: 41815833
wdFindContinue is not declared?
0
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41815834
corrected code
 
   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

1
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:RIAS
ID: 41815851
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

0
 

Author Comment

by:RIAS
ID: 41815853
Cheers!.

Is there a way I can replace the text with lower case?
0
 
LVL 48

Expert Comment

by:Rgonzo1971
ID: 41815856
try by replacing ^& in the replacement text with to:
0
 

Author Closing Comment

by:RIAS
ID: 41816162
Cheers mate!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now