Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As New System.Text.StringBuilder(My.Computer.FileSystem.ReadAllText("C:\temp\template.rtf"))
s.Replace("%%firstname%%", "Joe")
s.Replace("%%lastname%%", "Smith")
s.Replace("%%address%%", "123 Woodland Dr")
My.Computer.FileSystem.WriteAllText("C:\temp\test.rtf", s.ToString, False, System.Text.Encoding.ASCII)
Process.Start("C:\temp\test.rtf") 'Just to display new RTF file
End Sub
End Class
|