terry Lowry

terry Lowry

  • NA
  • 1
  • 0

Creat a word application and use find and replace

Jan 11 2006 8:38 AM


  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