How far can i push MS word with macros?

  ShorN 11:15 25 Aug 2006

I work in a company that has many offices around the country.

From our office we refer work to other offices.
Each office looks after (for example an area covering 10 postcodes)

We are referring work by the way of a Word document referral. (a basic referral form that contains boxes for the info required)

What I want to know, is it possible...

To have a form/macro within the word document, that, when a I enter the postcode, the relevant office will be entered automatcially into the document.

Any help appreciated, please ask if there is anymore clarification needed!!

  Simsy 12:14 25 Aug 2006

it would be possible. I assume you want to automatically insert the appropriate address of the branch

The detail would mean searching a database.

I don't have the skills to do it... but I have no doubt someone here does. Good luck,



  skeletal 13:10 25 Aug 2006

Indeed it is possible, but to be honest you don’t want to!

The Word object model, putting it politely, has some interesting features! The problem you are outlining (if I have understood you correctly) is actually asking for a database solution and depending on which version of Office you have, you may already have Microsoft Access. This is good enough for small databases of typically up to a few million records. You can arrange for it to be used by up to about 10 to 20 users at the same time but it can get a bit flaky at this point.

Thus, you would have a database containing a table of your office addresses and associated details. You would have another table(s) containing information about what you call a “referral” i.e. there must be something that make you want to chose one office from another.

So, you may have different coloured cans of paint in each office. Your system would ask for paint colour. You enter “red” and it would list 3 offices that have red paint. You chose one of them (from other forms, or manually) and that could be arranged to open up a “report” or a Word template already filled in with all the office details and “red paint” i.e. it would be Access calling up Word, rather than Word trying to be a database which it definitely isn’t. You mention “boxes with the info required”, again this sounds like the info should be in the database and filled in to the Word form.

The system could be far more advanced, allowing you to search for information and give monthly reports of which office was called up the most, how much red paint was asked for etc etc.

I suggest you think of your problem in term of data, and how you store and manipulate it, rather than “writing a letter”. Unless you’ve used a database, this is not easy as we tend to think of solutions using stuff we are familiar with.

Also, either solution would involve a fairly steep learning curve.

On the other hand, I may have completely misunderstood you and all you need is a mail merge facility with Outlook.

Hope this helps.


  silverous 15:54 25 Aug 2006

You could do this with visual basic for applications. Word isn't really designed as an application 'front end' but it would be possible.

Do you have a list of every single post code and the associated office that deals with it?

Here's something similar, would you be comfortable doing this?

click here

To be honest you will need to be comfortable with that kind of thing if you have it as undoubtedly it will need to be maintained and expaneded.

  silverous 15:57 25 Aug 2006

Having said that, I've never done this before and it sounds interesting, so would be happy to have a go and send you a working example if you like :)

The above example involves populating an access database, I think it is best to store the offices and postcodes in access.

  silverous 15:57 25 Aug 2006

Alternatively you could do something similar without access and just hard-code the data in word or even in a text file. How many office/postcode combinations are we talking about?

  silverous 16:21 25 Aug 2006

OK so I have too much time on my hands.

Here's an example:

click here

I'm more of an excel vba person myself but it translates quite well into word so didn't take long. Let me know your thoughts.

  silverous 13:32 29 Aug 2006

Any comments shorn?

  silverous 12:05 01 Sep 2006

Nothing like putting the time and effort into an answer only for it to go deadly silent with no response ;)

  skeletal 19:46 04 Sep 2006

Hi silverous. I’ve been half watching this thread, and your notes, since I offered my thoughts. I suppose some people may make a request and then go on holiday for a time, or find their own solution and forget to let everyone know!

Ah well…I thought I’d respond so you’d know there’s someone else out there!


  silverous 19:59 04 Sep 2006

Thanks skeletal, may well be on holiday, I guess I was keen to hear how it went. These posts should generate an email so hopefully we'll hear (or can you choose not to be notified? Can't recall)

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Alienware 17 R4 2017 review

These brilliant Lego posters show just what children's imaginations are capable of

Mac power user tips and hidden tricks

Comment réinitialiser votre PC, ordinateur portable ou tablette Windows ?