+ Reply to Thread
Results 1 to 2 of 2

Word Find And Replace having problem

  1. #1
    Registered User
    Join Date
    Kansas City, MO
    MS-Off Ver
    Office 2016

    Word Find And Replace having problem

    I have a lot of code designed as such: an excel template is filled out with a bunch of data. Once it's generated, word templates are pulled and populated with that information, and saved to the OneDrive. In my first version of this 'generator', which worked fine, I created it not to save it to OneDrive, but just in the file path that the Workbook sits in. The code adjustment to create the new version was simple, simply changing the filepath. Additionally, I added a 'log' to keep a record of each 'generation' in a separate worksheet within the book. Now, something strange has happened in that it goes through the whole word document replacing data correctly, however before it closes the word file, it replaces the correct data with something else. Take for example, there is one field called, 'booking number'. It may look something like this: NAM361008. The replacement in the word file happens correctly at the initial stage in the Word Document, but during the replacement, it may become something like NAM36130008.... something of that nature. The information about the features I added may not be relevant, but have included incase.

    The code was created inspired by this example: [unable to post the link, but YouTube How To Create Custom Word Documents From Excel WITHOUT Mail Merge and see the video from Excel for Freelancers]

    The code is very long, so I am posting what I think are the most relevant snippets for perusal, and if it is deemed the problem may lie elsewhere I can post more.

    Two attachments are DocGenCodeNew (which is new version) and DocGenCodeOld (which is old version). In the new snippet, the code creates a folder in OneDrive, following which it uses a variable to parse a list of templates, opening them one by one and saving as before closing. The functionality is exactly as shown in the video above. In the old snippet, there is not folder created.

    Sorry for the long post, but tried to be as descriptive as possible. I will appreciate all the help I can get!
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    United States
    MS-Off Ver
    Excel 2007

    Re: Word Find And Replace having problem

    I would slow down the code by adding in application.wait Now + .00003 '(or whatever time)
    See if that helps if not at least you can watch what it is doing, every step of the way

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 15
    Last Post: 01-30-2018, 09:13 AM
  2. [SOLVED] Find text in word in the cell and replace whole word
    By Grens in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-31-2016, 01:44 PM
  3. [SOLVED] Help with macro to find a specific word and replace the entire cell with the return word.
    By BG1983 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 08-24-2015, 09:40 PM
  4. Replies: 3
    Last Post: 11-25-2014, 06:08 AM
  5. [SOLVED] Excel macro- Find replace an itallic font word with a regular word?
    By thisisaboutwork in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-08-2013, 01:48 PM
  6. Need help with Excel-to-Word find and replace macro based on word filename
    By EnterTheSerpent in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-16-2013, 12:48 PM
  7. find in excel replace in word: find/replace text in text boxes and headers
    By dean.rogers in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2012, 12:40 PM

Tags for this Thread


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