Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
 EXP Systems Forum : PDF reDirect : Programming
Topic: replace word one by one Post Reply Post New Topic
Author Message

Joined: 15 Aug 10
Location: Canada
Posts: 1
Quote hiaim Replybullet Topic: replace word one by one
    Posted: 15 Aug 10 at 5:52PM

if a word repeated several times in a word document following macro should ask to change before every occurrence/word. suppose word "facet" has to replace with "subject area" and "facet" is repeated 3 times in a document. it should ask to change at every word. i tried wdReplaceOne as well but it is not working ... any solution , any other way to achieve this ???

Dim a As Integer, myRange As Range
    mySearch = InputBox("Enter string to search for:", "Searchstring", "")
    myReplace = InputBox("Enter string to replace " & mySearch & " with:", "Replacestring", "")
    Selection.HomeKey Unit:=wdStory
    With Selection.Find
            .Text = mySearch
            .Replacement.Text = myReplace
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = True
            .MatchWholeWord = True
            .MatchByte = False
            .CorrectHangulEndings = True
            .MatchAllWordForms = False
            .MatchSoundsLike = False
            .MatchWildcards = False
            .MatchFuzzy = False
    End With
' Selection.Find.Execute
    Do While Selection.Find.Found = True
   ' If Selection.Find.Found = True Then
        a = MsgBox("Do you want to change?", vbYesNo, "Confirmation")
        If a = 6 Then
            Selection.Find.Execute Replace:=wdReplaceOne
            Selection.EndKey Unit:=wdStory
        End If
    'End If
IP IP Logged
Moderator Group
Moderator Group
Forum Administrator

Joined: 25 Jan 03
Posts: 1663
Quote Michel_K17 Replybullet Posted: 15 Aug 10 at 10:32PM

   You might have more luck posting in a forum that specifically caters to Word VBA coding. This forum is for PDF reDirect users, so you it is unlikely you will get an answer here.

Michel Korwin-Szymanowski
EXP Systems LLC
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum