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

There are many situations you may want to 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 into 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 with a 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:

  1. plese send the VBA code to kavyajeetbora@gmail.com

    ReplyDelete
  2. You have written an excellent blog. I learned something new from your Blog. Keep sharing valuable information.
    UI Design For Mobile Apps
    Mobile Application UI

    ReplyDelete

How to copy screenshot to clipboard in New Apple Mac OS

If you have upgraded your Apple Mac OS to 14.x.x, then you may find it strange that the screenshots are not copied into the clipboard. The s...