Wasted half a day ggogling but still none the wiser
I created in vb a text file c:\Sample.txt
after creating the file I want to print it
can't get the file to print, it just prints a blank document called document
I have the following code
Imports System.Configuration
Imports System.IO
Imports System.Drawing.Printing
Inherits System.Windows.Forms.Form
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
im strFileName As String
Dim objStreamToPrint As StreamReader
Dim objPrintFont As Font
'Declare an object for the PrintDocument class
Dim objPrintDocument As PrintDocument = New PrintDocument()
'Set the PrintDialog properties
PrintDialog1.AllowPrintToFile = False
PrintDialog1.AllowSelection = False
PrintDialog1.AllowSomePages = False
strFileName = "C:\Sample.txt" 'Set the Document property to the objPrintDocument object
PrintDialog1.Document = objPrintDocument
'Show the Print dialog
If PrintDialog1.ShowDialog() = DialogResult.OK Then
'If the user clicked on the OK button then set the StreamReader
'object to the file name in the strFileName variable
objStreamToPrint = New StreamReader(strFileName)
'Print the text file
objPrintDocument.Print()
'Clean up
objStreamToPrint.Close()
objStreamToPrint = Nothing
End If
ANY IDEAS?
I created in vb a text file c:\Sample.txt
after creating the file I want to print it
can't get the file to print, it just prints a blank document called document
I have the following code
Imports System.Configuration
Imports System.IO
Imports System.Drawing.Printing
Inherits System.Windows.Forms.Form
Dim oFile As System.IO.File
Dim oWrite As System.IO.StreamWriter
im strFileName As String
Dim objStreamToPrint As StreamReader
Dim objPrintFont As Font
'Declare an object for the PrintDocument class
Dim objPrintDocument As PrintDocument = New PrintDocument()
'Set the PrintDialog properties
PrintDialog1.AllowPrintToFile = False
PrintDialog1.AllowSelection = False
PrintDialog1.AllowSomePages = False
strFileName = "C:\Sample.txt" 'Set the Document property to the objPrintDocument object
PrintDialog1.Document = objPrintDocument
'Show the Print dialog
If PrintDialog1.ShowDialog() = DialogResult.OK Then
'If the user clicked on the OK button then set the StreamReader
'object to the file name in the strFileName variable
objStreamToPrint = New StreamReader(strFileName)
'Print the text file
objPrintDocument.Print()
'Clean up
objStreamToPrint.Close()
objStreamToPrint = Nothing
End If
ANY IDEAS?