+ Reply to Thread
Results 1 to 6 of 6

Search and Replace... from Excel to Word

  1. #1
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    604

    Search and Replace... from Excel to Word

    I have numerous Word documents in a folder with the string... "Jimmy" throughout them. I would like to enter the name "Bob" into an Excel cell, run a macro, and have it search and replace all occurrences of "Jimmy" with "Bob" in all Word documents in the folder. Can this be done?

    Thx!
    Last edited by Xx7; 02-27-2011 at 03:06 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Search and Replace... from Excel to Word

    Hello Xx7,

    This macro should do what you want. You will need to change the directory and the cell that will hold the search word to what you will be using
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    604

    Re: Search and Replace... from Excel to Word

    Thanks Leith,

    I believe a minor adjustment should possibly be made. I have the following Word docs in my target folder: "Document1", "Document2", "Document3"

    When I run it, it gives an error message...

    This file could not be found.
    (C:Windows\system32\Document1.doc)


    My target folder is: C:\Users\BD\Desktop\Folder

    I'm assuming it's searching a different folder than expected?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Search and Replace... from Excel to Word

    Hello Xx7,

    Try this version of the macro. You may want to change the FileType from ".doc" to ".docx". Otherwise it may try to open any Word document it finds.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    604

    Re: Search and Replace... from Excel to Word

    Beauty... it works! I just changed:

    wdDoc.Close SaveChanges:=False

    to

    wdDoc.Close SaveChanges:=True
    Last edited by Xx7; 02-27-2011 at 03:04 PM.

  6. #6
    Forum Contributor
    Join Date
    01-30-2011
    Location
    Vancouver, Canada
    MS-Off Ver
    Excel 2010
    Posts
    604

    Re: Search and Replace... from Excel to Word

    Final code:


    Please Login or Register  to view this content.
    Thanks Leith!!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1