DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6

Thread: Printing issue

  1. #1
    Join Date
    Mar 2005
    Posts
    96

    Printing issue

    I want my program to open a word document and print it to the defulat printer without showing the printer box of commondialog. How should i do that? Right now i have:

    Private Sub Print_Click()
    CommonDialog1.Flags = cdlPDReturnDC + cdlPDNoPageNums
    If choices.RTB1.SelLength = 0 Then
    CommonDialog1.Flags = CommonDialog1.Flags + cdlPDAllPages
    Else
    CommonDialog1.Flags = CommonDialog1.Flags + cdlPDSelection
    End If
    Printer.DeviceName
    CommonDialog1.ShowPrinter
    Printer.Print ""
    choices.RTB1.SelPrint CommonDialog1.hDC
    End Sub

    where, choices is my form; RTB1 is a richtextbox.

    Thanks ~svn

  2. #2
    Join Date
    Nov 2004
    Posts
    293
    I belive your line of : CommonDialog1.ShowPrinter

    is what shows the common dialog, so what happens if you leave this line out???

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Simply delete all references to CommonDialog1:
    Code:
    Private Sub Print_Click()
        Printer.Print ""
        choices.RTB1.SelPrint Printer.hDC
    End Sub
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  4. #4
    Join Date
    Mar 2005
    Posts
    96
    hahahahahaha.... i think when i read "commondialog.showPrinter' i figured out which line was showing the Printer box!

    in any case, i tried that. It gave me an error because it does not have any value for Printer.hDC.

    the exact error is:
    Run-time error '32001'
    Invalid HDC.

  5. #5
    Join Date
    Mar 2005
    Posts
    96
    i see. you changed the commondialog.hdc with printer.hdc.

    but that still did nto work. it printed a page with error messages which goes somehting like:
    PCL XL error
    subsystem:kernel
    error:illegalstreamheader
    operator:0x0
    Position:0

  6. #6
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    This is a printer error; it has nothing to do with VB. According to http://h20000.www2.hp.com/bizsupport...ctID=c00041744, if the error occurs consistently, you should try using a different printer driver. If it occurs intermittently, it's likely a communications issue.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links