Jump to content
Sign in to follow this  

Word Macro for automating form to enter fields

Recommended Posts


I have some long Word templates that require multiple changes to names, dates, amounts, and other specific entries.

I would like to just open the Word template and go from there. It would be like find-and-replace except you could make a list of the find-replace pairs and then click GO somehow.

I assume the autoit code would be housed under Tools/Macros.

As a newbie, I understand that autoit will do this, but I cannot seem to get started.

I cannot even seem to open a document using autoit or figure out what all those things are that were downloaded for autoit.

All help greatly appreciated.


Edited by GaryMN

Share this post

Link to post
Share on other sites


Welcome to the AutoIt forum. :)

We can all remember the feeling when we started coding! Believe me, it does pass with time - although you have to make an effort to learn as you go along. Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here. They will give you a good grounding in AutoIt and then you should feel less lost. ;)

As to your immediate problem, I would suggest using FileRead to get the content of the Word Templates into a variable and then use StringReplace to change the contents. Give it a try and see how you get on - you know where we are if you run into difficulties. :)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:


ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area


Share this post

Link to post
Share on other sites


there are quite a few examples in the help files directory on using MS Word, essentially using COM to "remote control" MS Word.

For me, it's simpler if I first create the basic code to use in VBA. You can most times do this using the macro recorder. Then you just translate the completed VBA code to the COM syntax. It should be not-that-difficult, if you look closely at help file examples, and perhaps at the MSDN documentation.

In your current example, I would create (named) bookmarks if possible, bookmarks can be either a position or a range.

Sometimes when asking quesions here, it's a good idea to post example documents / code. Makes it simpler to help you.

I am just a hobby programmer, and nothing great to publish right now.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this