L
louis vilan
I would like to get a little code help on a project. I am only now
starting to learn VB, and to this point, I have tried VB on a limited
basis in Access.
Here's what I am working on that prompted me to ask for your help. I
have a Word 2003 mail merge main document that has about 40 mail merge
fields on it, so you can imagine the size of the Word data source
table. On the main document, I have a table laid out that I would like
to format during the merge, and the format would be conditional and
based on the value merged into onje of the fields. Basically, what I am
trying to do is to format the table as a bar chart; if the value of the
merged field is "1", one cell of the table changes color; if the value
of the merge is "2" then another cell of the table changes color; the
value of the field can also be "3" or "4" and the format would again
change on the value. I have about 100 records in my data table;
actually, it's an ascii txt file with 40 fields and 100 records I
export from Access.
I know I can control the color of the table cells because I have
recorded a couple macros that will automatically format the cells the
way I want them.Unfortunately, Word VB seems like the cruel step child
of VBA I am starting to learn in Access.
In plain english, here are the steps I want to do:
1. During the merge, when mergeField1 on the main doc receives a value
of "1" from the data source, the VB code should run Macro1. Macro1 is a
macro I recorded that will reformat a table cell on the main doc. The
macro knows where the cell is because there is a bookmark in the cell.
If the value is "2", the code should call Macro2, which already has
been recorded to reformat 2 cells, and so on.
2. After reformatting the cell, the merge should continue with the rest
of the fields on the main doc.
I can see the code for the reformatting macros I recorded, so if I can
get help on the code that can determine which macro to call, I'll be in
good shape. I am trying to figure out the Word VB events, so if you can
help me on the code, I'd also like to know wgat event to use to fire
the code.
Thanks to anyone who can help!
starting to learn VB, and to this point, I have tried VB on a limited
basis in Access.
Here's what I am working on that prompted me to ask for your help. I
have a Word 2003 mail merge main document that has about 40 mail merge
fields on it, so you can imagine the size of the Word data source
table. On the main document, I have a table laid out that I would like
to format during the merge, and the format would be conditional and
based on the value merged into onje of the fields. Basically, what I am
trying to do is to format the table as a bar chart; if the value of the
merged field is "1", one cell of the table changes color; if the value
of the merge is "2" then another cell of the table changes color; the
value of the field can also be "3" or "4" and the format would again
change on the value. I have about 100 records in my data table;
actually, it's an ascii txt file with 40 fields and 100 records I
export from Access.
I know I can control the color of the table cells because I have
recorded a couple macros that will automatically format the cells the
way I want them.Unfortunately, Word VB seems like the cruel step child
of VBA I am starting to learn in Access.
In plain english, here are the steps I want to do:
1. During the merge, when mergeField1 on the main doc receives a value
of "1" from the data source, the VB code should run Macro1. Macro1 is a
macro I recorded that will reformat a table cell on the main doc. The
macro knows where the cell is because there is a bookmark in the cell.
If the value is "2", the code should call Macro2, which already has
been recorded to reformat 2 cells, and so on.
2. After reformatting the cell, the merge should continue with the rest
of the fields on the main doc.
I can see the code for the reformatting macros I recorded, so if I can
get help on the code that can determine which macro to call, I'll be in
good shape. I am trying to figure out the Word VB events, so if you can
help me on the code, I'd also like to know wgat event to use to fire
the code.
Thanks to anyone who can help!