Sunday, April 17, 2016

How to create MS Word document automatically by inserting text file content to the word document

There are many situations you may want automate the MS Word document creation. In my previous posts, I have explained how to automate document generation using VBA. It was to create a new document. Every time you run the VBA code, it will create a new MS Word file.

How to create a template in MS Word

Now, I will explain how to insert a text file into the document as is at a specified location into an existing document. This is very useful if you are modifying an existing document. The main feature of this VBA is, it can insert new content at a specific location. That means you can insert new content in to any part of the existing document, not just append the new content at the end of the file. The first step is to create a bookmark in the word document where the text file content will be pasted. Then, open the text file using VBA code and paste the content at the bookmark. Save the file as with different name. Before saving optionally you can remove the bookmark.

Below video shows details steps to insert a text file into MS word document


2 comments:

VBA Code to copy and paste the Content from excel to word

There are situations where you may have to copy and paste some content from excel to word. And save the newly created document into disk. Th...