+ Reply to Thread
Results 1 to 4 of 4

Need help with Excel-to-Word find and replace macro based on word filename

  1. #1
    Registered User
    Join Date
    10-15-2012
    Location
    Seattle
    MS-Off Ver
    Excel 2003
    Posts
    3

    Need help with Excel-to-Word find and replace macro based on word filename

    Forgive me if this is a dumb question or not possible, I'm very new to all of this...

    Basically, I want to run a macro from Excel that will open all Word documents in a specified folder and run a find-and-replace on them based on the names of the Word documents. The names of the Word documents will be present in Excel cells. So basically, I want to be able to point the macro to a folder and have it open every Word document within, and if, for example, the file name matches the contents of cell A1, have it replace a pre-specified term wherever it appears in that Word file with the contents of cell B1. I'm trying to get it to a simple find-and-replace on just one file before I get into the opening multiple files and using the file name as criteria parts, and I can't even get that to work. What I have so far is

    Please Login or Register  to view this content.
    I'm getting error 438: object doesn't support this property or method. Any help would be greatly appreciated.


    Moderator's Note: Welcome to the forum, you have to put code tags around codes. Select the code then hit the "#". I'll do it for now. Thank you.
    Last edited by vlady; 01-16-2013 at 01:51 AM. Reason: code tags

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Need help with Excel-to-Word find and replace macro based on word filename

    with this code I can replace only first occurrence
    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Registered User
    Join Date
    10-15-2012
    Location
    Seattle
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Need help with Excel-to-Word find and replace macro based on word filename

    Thanks Patel45, I should have mentioned that there will only be one instance of each term to be replaced in each file, so it doesn't need to work for multiple occurrences in the same Word Doc; that's definitely a good start.

    The next part is that I really need it to work on multiple Word documents at once that will be in the same folder, and unfortunately the name of the folder will change every day so listing the folder name in the VBA code isn't terribly practical...I have another macro that, when run, opens a box that allows you to browse for a folder and then it does what it does to every file in the folder, I'm hoping something like that might be doable here. That other macro just lists the file names in Excel as opposed to executing a find and replace which is what I need it to do here, so I'm not sure if it's possible to use the same method in this case. Thanks again for your help.

  4. #4
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Need help with Excel-to-Word find and replace macro based on word filename

    try this
    Please Login or Register  to view this content.

+ 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