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!
Bookmarks