I have an application that takes form inputs, searches an RTF document and replaces where appropriate, and writes back out to an RTF.
I want a button that i can press that will then pick up that RTF and send it to the printer.
I've got it to communicate with the printer but all i get is a blank sheet of paper.
My print button code is:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim printdoc As New Printing.PrintDocument
End Sub
Or without the dialog:
Dim printme As New Printing.PrintDocument
printme.DocumentName = "c:\dataprep-output.rtf"
printme.Print()
I will be grateful if anyone can shed any light on why all i get at the end is a blank piece of paper!
Or if anyone can tell me an easier way to do the same function (i do need it to output to an RTF before printing so cannot simplify it there)
BTW i'm using VB 2005 Express
Thanks
Pedro
I want a button that i can press that will then pick up that RTF and send it to the printer.
I've got it to communicate with the printer but all i get is a blank sheet of paper.
My print button code is:
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim printdoc As New Printing.PrintDocument
PrintDialog1.PrinterSettings = printdoc.PrinterSettings
If PrintDialog1.ShowDialog() <> Windows.Forms.DialogResult.Cancel Then
If File.Exists(System.Windows.Forms.Application.StartupPath() & "\Outputs\dataprep-output.rtf") Then
MsgBox("File exists", MsgBoxStyle.OkOnly)
printdoc.DocumentName = System.Windows.Forms.Application.StartupPath() & "\Outputs\dataprep-output.rtf"
printdoc.Print()
Else
MsgBox("File does not exist", MsgBoxStyle.OkOnly)
End If
End If
printdoc.Dispose()
End Sub
Or without the dialog:
Dim printme As New Printing.PrintDocument
printme.DocumentName = "c:\dataprep-output.rtf"
printme.Print()
I will be grateful if anyone can shed any light on why all i get at the end is a blank piece of paper!
Or if anyone can tell me an easier way to do the same function (i do need it to output to an RTF before printing so cannot simplify it there)
BTW i'm using VB 2005 Express
Thanks
Pedro
Last edited: