Solved

how to use Find&Replace Object from WORD

Posted on 2000-05-07
4
159 Views
Last Modified: 2012-05-04
how to use Find&Replace Object from WORD

In VB App I'm using the MS Word Object,
I'm trying to use the Find and Replace Object.
but I get 'Automation Error'

please send a sample code.

0
Comment
Question by:david2001
4 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 2785454
Please post your actual code.
0
 

Author Comment

by:david2001
ID: 2785461
this is a few methods i tried

Dim a As Boolean

1)
a = wordApp.ActiveDocument.Content.Find.Execute(FindText:=CurOrgSentence)

-----------------------------------
2)
a = wordApp.Selection.Find.Text = "and"
    ReplaceWith:=CurTarSentence, Replace:=wdReplaceOne

-----------------------------------          
3)

wordApp.ActiveDocument.Select
         
With wordApp.Selection.Find
..Text = "and"
..Forward = True
..ClearFormatting
..MatchWholeWord = True
..MatchCase = False
..Execute FindText:="To"
End With
0
 
LVL 6

Accepted Solution

by:
Marine earned 50 total points
ID: 2785572
With Selection.Find
    .Forward = True
    .Wrap = wdFindStop
    .Text = "Hello"
    .Execute
End With

Here is the Link with lots of examples

http://msdn.microsoft.com/library/officedev/office97/web/007.htm#CH007H105
0
 
LVL 44

Expert Comment

by:bruintje
ID: 2786068
or

Selection.Find.ClearFormatting
    With Selection.Find
        .Text = "rt"
        .Replacement.Text = "cb"
        .Forward = True
        'wdFinContinue will replace all
        'wdFindAsk will ask at each found
        'wdFindStop will stop after the first replacement
        .Wrap = wdFindContinue
        .MatchWholeWord = True
    End With
    Selection.Find.Execute Replace:=wdReplaceAll

HTH:O)Bruintje
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

809 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