Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Trying to detect Cancel in ShowPrinter

Trying to detect Cancel in ShowPrinter

Scheduled Pinned Locked Moved Visual Basic
comtutorialquestion
2 Posts 2 Posters 8 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jamesdturner hotmail com
    wrote on last edited by
    #1

    I found what I thought to be an easy way to shove a graphical VB form to a printer. It works fine when I call ShowPrinter and change the print quality and click OK.... But I don't know how to pick up the Cancel button click of the CommonDialog1.ShowPrinter and avoid printing. Here's the code: CommonDialog1.ShowPrinter Form1.PrintForm (need to detect cancel w/in CommonDialog1.ShowPrinter - branch around Form1.PrintForm if Cancel is pressed) Any ideas? Thanks in advance, \\Jim CommonDialog1.ShowPrinter jamesdturner@hotmail.com

    A 1 Reply Last reply
    0
    • J jamesdturner hotmail com

      I found what I thought to be an easy way to shove a graphical VB form to a printer. It works fine when I call ShowPrinter and change the print quality and click OK.... But I don't know how to pick up the Cancel button click of the CommonDialog1.ShowPrinter and avoid printing. Here's the code: CommonDialog1.ShowPrinter Form1.PrintForm (need to detect cancel w/in CommonDialog1.ShowPrinter - branch around Form1.PrintForm if Cancel is pressed) Any ideas? Thanks in advance, \\Jim CommonDialog1.ShowPrinter jamesdturner@hotmail.com

      A Offline
      A Offline
      AndyG
      wrote on last edited by
      #2

      Try this: On Error GoTo ErrHandler CommonDialog1.CancelError = True CommonDialog1.ShowPrinter Form1.PrintForm Exit Sub ErrHandler: End Sub If you have existing Error Handling code the ErrHandler would look a little different: ErrHandler: If Err.Number <> 32755 Then '32755 is the Error Number for Cancel being selected 'Process Error as usual End If End Sub Andy Gaskell, MCSD

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups