I have a small macro I have written to take data from excel to populate word and have a slight problem. Here is a sample of the way I am doing it:
my problem is that there are 10 possible paragraphs that I have and this code inserts them all.
What I want to be able to do is input only paragraphs if they are sleected to be input on excel. I have input check boxes so the use can select if theyw ant that paragraph input.
I have the selected paragraphs highlighted in excel like this:
Paragraphs used :
2 TRUE
3 TRUE
4 FALSE
5 TRUE
6 TRUE
7 TRUE
8 TRUE
9 FALSE
10 TRUE
What I want to do is get the VB to recognise if a paragraph is not to be used and then so for the above the wordarray would be like this:
wordarray = Array(add1, add2, add3, add4, add5, blank, Pol1, yourref, OurRef, cudate, Salutation, para1, para3, para4, para5, para6, para7, para8, para10, name, position, blank, blank)
So it would omit para2 & para10 and instead leave the last 2 fields blank.
Can this be done?
many thanks
Code:
wrd.ChangeFileOpenDirectory _
"\\BTBEAPDAT01\DATA_BEACON_HOUSE\NCC\Tier3 RP|Damian Templates"
wrd.Documents.Open FileName:="T66 TV Payment Letter.doc", ReadOnly:=True, AddToRecentFiles:=False
wordarray = Array(add1, add2, add3, add4, add5, blank, Pol1, yourref, OurRef, cudate, Salutation, para1, para2, para3, para4, para5, para6, para7, para8, para9, para10, name, position)
wrd.ActiveDocument.Fields(1).Select
With wrd.Selection
.InsertAfter Text:=addressee
End With
For wrdroutine = 0 To 21
wrd.Selection.NextField.Select
With wrd.Selection
.InsertAfter Text:=wordarray(wrdroutine)
End With
Next
my problem is that there are 10 possible paragraphs that I have and this code inserts them all.
What I want to be able to do is input only paragraphs if they are sleected to be input on excel. I have input check boxes so the use can select if theyw ant that paragraph input.
I have the selected paragraphs highlighted in excel like this:
Paragraphs used :
2 TRUE
3 TRUE
4 FALSE
5 TRUE
6 TRUE
7 TRUE
8 TRUE
9 FALSE
10 TRUE
What I want to do is get the VB to recognise if a paragraph is not to be used and then so for the above the wordarray would be like this:
wordarray = Array(add1, add2, add3, add4, add5, blank, Pol1, yourref, OurRef, cudate, Salutation, para1, para3, para4, para5, para6, para7, para8, para10, name, position, blank, blank)
So it would omit para2 & para10 and instead leave the last 2 fields blank.
Can this be done?
many thanks