A
aehan
Hello all
I have made a user form to populate a Word 2003 template. I have added a
piece of code that exits the population of the document if the required
fields aren't filled in, it reads like the sample below:
If Len(Trim(cmbDiv.text)) <= 0 Or Len(Trim(cmbDept.text)) <= 0 Or
Len(Trim(txtEMail.text)) <= 0 Then
MsgBox "You must fill in all the required fields"
Exit Sub
ElectronicOption.Enabled = True
End If
The code works, however what happens is that if the code is exited the form
has already placed some data in the template, and it duplicates it. So
instead of for example seeing the Department name as "Sales and Marketing",
you see it as "Sales and Marketing Sales and Marketing". I thought I would
have to write something like me.refresh before Exit Sub, but I can't find
anything in Word vba like that, I tried Repaint, but that didn't work.
I think the problem is that the data is already there, and when the rest of
the fields are filled in and the OK button clicked, the fact that some of the
data was already there is not recognised, and in that case I don't know what
to do. Does anyone have any ideas?
Thanks for all your help
Aehan
I have made a user form to populate a Word 2003 template. I have added a
piece of code that exits the population of the document if the required
fields aren't filled in, it reads like the sample below:
If Len(Trim(cmbDiv.text)) <= 0 Or Len(Trim(cmbDept.text)) <= 0 Or
Len(Trim(txtEMail.text)) <= 0 Then
MsgBox "You must fill in all the required fields"
Exit Sub
ElectronicOption.Enabled = True
End If
The code works, however what happens is that if the code is exited the form
has already placed some data in the template, and it duplicates it. So
instead of for example seeing the Department name as "Sales and Marketing",
you see it as "Sales and Marketing Sales and Marketing". I thought I would
have to write something like me.refresh before Exit Sub, but I can't find
anything in Word vba like that, I tried Repaint, but that didn't work.
I think the problem is that the data is already there, and when the rest of
the fields are filled in and the OK button clicked, the fact that some of the
data was already there is not recognised, and in that case I don't know what
to do. Does anyone have any ideas?
Thanks for all your help
Aehan