Thanks Tony - I really appreciate your help.
That worked fine.
One last thing that you might be able to help with.
Rather than creating a new document I have opened a Word template with :-
objWord.Documents.Open "C:\Form.dot"
The form has several Form Fields. I need to access some of these form fields
and then write some text (still from Excel).
I tried :-
Set wdRn = objDoc.FormFields(2).Range
With wdRn
.InsertAfter "fred"
End With
That worked but 'fred' appeared after the Form field. I need the field
itself to be overtyped with 'fred'
I wondered about using bookmarks possibly. I also tried using Select such as
:-
objDoc.FormFields(2).Select
Selection.TypeText Text:="fred"
This method generates an error :-
'Object does not support Property or Method'
Can you please advise?
Thanks again.
> Set objDoc = objWord.Documents.Add
>
[quoted text clipped - 52 lines]
> >
> > Thanks.
Tony Jollans - 12 Dec 2007 16:25 GMT
Well, you shouldn't really use templates like that; the idea is that you
create new documents based on them.
Regardless of that, if FormFields have names, those names *are* bookmarks.
To assign some text to a formfield itself you should use the Result Range,
so
objDoc.FormFields(2).Result + "Your text here"
(if your text is longer than 255 characters see
http://word.mvps.org/faqs/MacrosVBA/SetLongFmFldResult.htm)

Signature
Enjoy,
Tony
> Thanks Tony - I really appreciate your help.
>
[quoted text clipped - 94 lines]
>> >
>> > Thanks.
Andy - 12 Dec 2007 16:55 GMT
Brilliant - Thanks again Tony.
I have also taken your advice about incorrect use of template. I have
changed :-
objWord.Documents.Open "C:\Form.dot"
to :-
objWord.Documents.Add Template:="C:\Form.dot",
DocumentType:=wdNewBlankDocument
> Well, you shouldn't really use templates like that; the idea is that you
> create new documents based on them.
[quoted text clipped - 106 lines]
> >> >
> >> > Thanks.