I am writing an app in VB to create and write to a word document.

The document will be using a template with a couple of text string tags in it, the idea being that a new document is created, the tag is found and replaced by my text.

I am nearly there, I have got the find working ok and going to the text tag, but then when I use the selection object to change the text it is referencing a previously opened document, I can't get it to refer to my document.

Here is the code, as I say, it is fine as long as mine is the only document open, otherwise the text seems to end up on one of the others. Can anyone help?

mObjDocument.Select

Selection.Find.ClearFormatting
With Selection.Find
.Text = TOTAL_LOCATION_TEXT
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute

If Selection.Text = TOTAL_LOCATION_TEXT Then
Selection.TypeText "Net Total = " & FormatCurrency(prcNetTotal)
Else
MsgBox "Tag not found"
End If

Thanks

Robin