[RESOLVED] Is it possible to.... ?
I have a basic piece of coding done,
It works like this:
I select a surname from a listbox, this loads their address & eye test results.
(loads into text boxes)
I then click order.
(loads a new form *orderform.vb*)
Now I can enter information into 4 text boxes...
I would like the surname, address & results to get sent to a letter, and then the new information from the text boxes to get sent to a letter... (.doc or .txt)
But it has to get sent to a specific part of a pre-written letter...
Is any of that possible?
As always, thanks guys. :wave:
Re: Is it possible to.... ?
create a standard letter template + put place holders in your letter - i.e. [field1], [field2], etc, which you can replace with surname, address & results.
Re: Is it possible to.... ?
Ok thanks, ehm how do I go about that?
And what is the VB code then to write into those fields?
Thanks!
Re: Is it possible to.... ?
try this:
this is an example template txt file:
Code:
[field1]
[field2]
Dear [field1],
This is a standard letter that you'll use as a template.
this is how to use it:
vb Code:
Dim txtFile As String = IO.File.ReadAllText("template.txt")
txtFile = txtFile.Replace("[field1]", "Mr Doe")
Dim address As String = "Address line1" & Environment.NewLine & New String(ChrW(Keys.Tab), 5) & _
"Address line2" & Environment.NewLine & New String(ChrW(Keys.Tab), 5) & _
"City" & Environment.NewLine & New String(ChrW(Keys.Tab), 5) & "Country"
txtFile = txtFile.Replace("[field2]", address)
IO.File.WriteAllText("newtxtFile.txt", txtFile)
Process.Start("newtxtFile.txt")
edit:
Re: Is it possible to.... ?
That's great, thanks... :)
Re: [RESOLVED] Is it possible to.... ?
to automate your printing, use this:
vb Code:
Dim pr As New ProcessStartInfo
With pr
.FileName = "newtxtFile.txt"
.WindowStyle = ProcessWindowStyle.Hidden
.Verb = "Print"
End With
Process.Start(pr)