Click here to Skip to main content
16,008,175 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionenvironment similar to excel??? Pin
drmzunlimited17-Oct-02 21:19
drmzunlimited17-Oct-02 21:19 
Questiondisable close and starting maximized? Pin
drmzunlimited17-Oct-02 21:05
drmzunlimited17-Oct-02 21:05 
AnswerRe: disable close and starting maximized? Pin
goddess_spanky18-Oct-02 4:58
goddess_spanky18-Oct-02 4:58 
GeneralMAPI session.logon Pin
Anonymous16-Oct-02 2:49
Anonymous16-Oct-02 2:49 
GeneralSKinning in VB.net Pin
308holes15-Oct-02 8:28
308holes15-Oct-02 8:28 
Generalhowto get fileinformation Pin
mkrelli15-Oct-02 7:20
mkrelli15-Oct-02 7:20 
GeneralRe: howto get fileinformation Pin
Richard Deeming16-Oct-02 1:40
mveRichard Deeming16-Oct-02 1:40 
GeneralPrint Word Document Pin
Zulfikar Ali15-Oct-02 6:22
Zulfikar Ali15-Oct-02 6:22 
i am trying to print word document in VB .net. it is printing the document but it is priting couple of lines of boxes in the beginning. any idea why is doing so. here is the code:

Public Sub PrintDoc()
Dim strPCLPrint As String
strPCLPrint = Trim(lblPCLPrinter.Text.ToString)
'ByVal strDocFile As String
'pcl Print driver
Try
StreamToPrint = New StreamReader("C:\temp\6031044.doc")
Try
Dim pr As New PrinterSettings()
pr.PrinterName = strPCLPrint
MsgBox(pr.PrinterName)
printFont = New Font("Arial", 10)

Dim pd As PrintDocument = New PrintDocument()
'sets the PCL printer for doc printing
AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
'pd.CreateObjRef()
pd.DocumentName = "C:\temp\6031044.doc"
pd.Print()
Catch ex As Exception
MessageBox.Show(ex.ToString)
Finally
StreamToPrint.Close()
End Try
Catch ex As Exception
MessageBox.Show("An error occurred printing the file - " + ex.Message)
End Try
End Sub

Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs)
Dim lpp As Single = 0
Dim yPos As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = ev.MarginBounds.Left
Dim topMargin As Single = ev.MarginBounds.Top
Dim line As String

'Work out the number of lines per page
'Use the MarginBounds on the event to do this
lpp = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)

'Now iterate over the file printing out each line
'NOTE WELL: This assumes that a single line is not wider than the page width
'Check count first so that we don't read line that we won't print
line = StreamToPrint.ReadLine()
While (count < lpp And line <> Nothing)

yPos = topMargin + (count * printFont.GetHeight(ev.Graphics))

'Print Preview control will not work.
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, _
yPos, New StringFormat())

count = count + 1

If (count < lpp) Then
line = StreamToPrint.ReadLine()
End If

End While
'If we have more lines then print another page
If (line <> Nothing) Then
ev.HasMorePages = True
Else
ev.HasMorePages = False
End If
End Sub

Thank you.Confused | :confused:

Zulfikar Ali
GeneralRe: Print Word Document Pin
Chad Smith15-Oct-02 7:12
professionalChad Smith15-Oct-02 7:12 
Generalcreate "excel" sheet in MDI (child) window Pin
sleepycat14-Oct-02 22:37
sleepycat14-Oct-02 22:37 
Generalprogrammer wanted Pin
Paul Rego14-Oct-02 18:34
sussPaul Rego14-Oct-02 18:34 
GeneralTab Control Pin
injunjoe14-Oct-02 15:40
injunjoe14-Oct-02 15:40 
GeneralSend and receive data Pin
Vipul Bhatt13-Oct-02 19:33
Vipul Bhatt13-Oct-02 19:33 
GeneralRe: Send and receive data Pin
RichardGrimmer20-Nov-02 2:15
RichardGrimmer20-Nov-02 2:15 
Questionhow to get value of one textbox from one form to another in VB.NET? Pin
drmzunlimited13-Oct-02 19:28
drmzunlimited13-Oct-02 19:28 
AnswerRe: how to get value of one textbox from one form to another in VB.NET? Pin
Nick Parker14-Oct-02 1:52
protectorNick Parker14-Oct-02 1:52 
GeneralCollections Pin
mikasa11-Oct-02 6:40
mikasa11-Oct-02 6:40 
GeneralRe: Collections Pin
Nick Parker11-Oct-02 8:11
protectorNick Parker11-Oct-02 8:11 
GeneralASCII Printable Characters Only Pin
Like2Byte10-Oct-02 5:10
Like2Byte10-Oct-02 5:10 
GeneralRe: ASCII Printable Characters Only Pin
Daniel Turini10-Oct-02 5:13
Daniel Turini10-Oct-02 5:13 
GeneralRe: ASCII Printable Characters Only Pin
Like2Byte10-Oct-02 5:45
Like2Byte10-Oct-02 5:45 
GeneralRe: ASCII Printable Characters Only Pin
Richard Deeming11-Oct-02 0:45
mveRichard Deeming11-Oct-02 0:45 
GeneralCopying controls Pin
Chris Hooper10-Oct-02 3:40
Chris Hooper10-Oct-02 3:40 
GeneralRe: Copying controls Pin
Daniel Turini10-Oct-02 3:58
Daniel Turini10-Oct-02 3:58 
GeneralRe: Copying controls Pin
Chris Hooper10-Oct-02 5:32
Chris Hooper10-Oct-02 5:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.