PDA

View Full Version : Need advice on using VBA with Word



OM2
06-05-2014, 06:41 PM
I have a CSV files with 20 records (this number can vary)

I want a Word document that uses a single page template and fills in data read in from the CSV file - and results in 20 pages being created from the single template

The only thing is that the data in the CSV file needs to be re-ordered and some logic applied
Would it be a good idea to do this is VBA?
I could get this done somewhere else - like write a standalone program that does this for me (I;d do this if it wasn't quick doing within VBA and Word)

Question: let's assume my CSV file doesn't need reordering and the data needs to simply be read in, is doing a mail merge the best way to create 20 pages? If so, what is the best format for the file? Is it CSV? Or something else like XML?

Thanks


OM

macropod
06-05-2014, 10:32 PM
Mailmerge is certainly a viable option, even if you're re-ordering the data. Depending on what 'logic' you're trying to apply, the mailmerge could possibly do that too.

OM2
06-06-2014, 08:20 AM
thanks for the reply

how slow is mailmerge? many many (10 or so years!) a friend of mind showed him using
it used to take a very very long time to complete

is csv the best file format?

the logic:

- some text needs to be capitalised up or down
- the records need to be re-ordered and grouped
- if one of the values is international, then a different graphic needs to be used, otherwise use something else

there are one or 2 other things... but the above would be ok for now

let me know

thanks

macropod
06-06-2014, 03:54 PM
how slow is mailmerge?
That's rather like asking how long is a piece of string. It all depends on how many records you're merging, how complex the merge is and the speed of your computer.

is csv the best file format?
There is no 'best' format. Word is equally happy working with csv files, Word tables, Excel workbooks, databases, etc.

the logic:

- some text needs to be capitalised up or down
- the records need to be re-ordered and grouped
- if one of the values is international, then a different graphic needs to be used, otherwise use something else

Mailmerges can handle all of that.