S
Simon
Any assistence for the following problem will be most appreciated.
I am writing a macro that takes codes and text from one document, called
Structure.doc and inserts the text, and text associated with several codes
[which are stored in tables in several other word documents] into an existing
report.
The codes are stored in a word document that contains 1 table with 2
columns. The first column hads the code, the second column has the text
[which may include numbering, formating, tables etc]
This macro works fine.
However, in the Strucutre document, I need to be able to toggle the codes on
and off where on displays just the codes, and off displays the full text
assosated with the code, just as in the Mail Merge preview.
However, as the codes are stored in several documents, and only certain
codes from each document are selected, I do not think I can use the in-built
Mail-merge function.
My thought was to use a mail merge field that the user could enter the code
in the field, and then use a macro to insert the field Result from the
appropriate document. I found this will work if using the
fields(i).Result.text except that tables and all the formating is lost.
From my understanding, the fields(i).Result is a range object and so I
should be able to insert a Selection.Range object into the fields(i).Result.
However, whenever I use the code:
ReportDoc.fields(i).Result = Selection.Range
word crashes. Can anyone explain what I am doing wrong?
If the above is not clear enough, let me know and I will try to reword.
Thanks,
Simon
I am writing a macro that takes codes and text from one document, called
Structure.doc and inserts the text, and text associated with several codes
[which are stored in tables in several other word documents] into an existing
report.
The codes are stored in a word document that contains 1 table with 2
columns. The first column hads the code, the second column has the text
[which may include numbering, formating, tables etc]
This macro works fine.
However, in the Strucutre document, I need to be able to toggle the codes on
and off where on displays just the codes, and off displays the full text
assosated with the code, just as in the Mail Merge preview.
However, as the codes are stored in several documents, and only certain
codes from each document are selected, I do not think I can use the in-built
Mail-merge function.
My thought was to use a mail merge field that the user could enter the code
in the field, and then use a macro to insert the field Result from the
appropriate document. I found this will work if using the
fields(i).Result.text except that tables and all the formating is lost.
From my understanding, the fields(i).Result is a range object and so I
should be able to insert a Selection.Range object into the fields(i).Result.
However, whenever I use the code:
ReportDoc.fields(i).Result = Selection.Range
word crashes. Can anyone explain what I am doing wrong?
If the above is not clear enough, let me know and I will try to reword.
Thanks,
Simon