[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Wordmerge

Posted on 2016-09-26
8
Medium Priority
?
97 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 53

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 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
 

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 53

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

656 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