0
Answer

Creat a word application and use find and replace

terry Lowry

terry Lowry

19y
1.8k
1


  In VB6 I can set a reference to word then create a word.application and find and replace brackets in a word template.I try and do the same thing in Vb.net and it does not work .
this is my usual VB6 code does anyone know what is wrong
Dim mWord As Word.Application
Set mWord = New Word.Application

Screen.MousePointer = vbHourglass
'get the correct template

mWord.Documents.add (App.Path & "\" & "Spanish1.dot")

'Replace the fields from the textboxes
mWord.Selection.Find.Execute findtext:="[ID]", replacewith:=txtclientnumber, Replace:=wdReplaceAll
mWord.Selection.Find.Execute findtext:="[TITLE]", replacewith:=txtdetails(0).Text, Replace:=wdReplaceAll
mWord.Selection.Find.Execute findtext:="[INITIALS]", replacewith:=txtdetails(14).Text, Replace:=wdReplaceAll
                                
mWord.Visible = True