Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
| Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2005, 11:21 PM
Registered User
 
Join Date: Jan 2005
Location: jsr, jharkhand, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default to print a file thourgh vb6 code

   i want to print a doc/txt/xls file through vb code .
   i have some code which is printing txt file but not a DOC file as well as other files.
  pls help me....


'================ browse button =============================='

 Private Sub cmdBrowse_Click()
Dim tcontent
On Error GoTo errmsg
cmdia1.DefaultExt = "rtf"
    cmdia1.Filter = "RTF Files|*.rtf|Doc Files|*.doc|Text files|*.txt|all_files|*.*"
    cmdia1.ShowOpen
    txtFile.Text = cmdia1.FileName
    RichTextBox1.Text = ""
    RichTextBox1.LoadFile cmdia1.FileName, rtftext
     openfile = cmdia1.FileName


Exit Sub
errmsg:
MsgBox Err.Description
End Sub


'========================= Printing ========================'
RichTextBox1.SelPrint Printer.hDC



 
Old April 21st, 2005, 02:59 PM
Friend of Wrox
 
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

If the rich textbox recognizes the format, and can display it properly, it should be able to print it.

But It will not have then necessary specific file-format information to handle a .doc nor a .xls.

You will need to 'read' these files yourself (that is, through code that you write) and pass an rtf equivalent to RichTextBox1.text.

Alternatively, open the appropriate application through Automation, tell it to open the file, then tell it to print the file through the methods that the applications class exposes.




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Print using Dot Matrix printer in VB6.0 sabsait Pro VB 6 5 October 10th, 2009 03:17 PM
How to create database (.mdb) file in vb6 code mrleokarthik Pro VB 6 13 August 7th, 2009 11:39 AM
How to set the print properties of excel with vb6 wyq1234 Visual Basic 2005 Basics 0 July 5th, 2006 10:09 AM
Print and print preview file on the website withou appleLover General .NET 0 February 19th, 2005 02:24 AM
getting print dialog box in vb6 as in ms-word mohanbabu Access VBA 0 December 22nd, 2003 01:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.