CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2001
    Location
    USA
    Posts
    161

    ShellExecute "print" Question

    Hi there,
    I know this was asked b4 but i never found the answer..
    I am trying to print a lot of files from my program and the code is more or less:

    for i = 0 to totalreport
    Call ShellExecute(Me.hWnd, "print", p_ReportFileName, "", "", 0)
    next i

    I know ShellExecute send it to the default printer, but i was wondering if there is any way i could show the printer dialog box to the user for him to choose what printer to use?

    Thanks in advance
    ---------------------------------------------
    Sure i got it... what s a form again?

  2. #2
    Join Date
    Apr 2004
    Posts
    14
    why don't you show a print dialog before calling the shellexecute to print ?

  3. #3
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    Use the common dialog control to pick your printer before you go into the loop, and use printer.print to print the doc rather than shellexecute.
    Be nice to Harley riders...

  4. #4
    Join Date
    Apr 2001
    Location
    USA
    Posts
    161
    Thanks for your help but i still have a problem. When i try to print the pdf file, it takes a long time to upload some data to the printer (name Microsoft Visual Basic) then it hangs till i quit the program, and i get a 'Printer Error'
    I am doing something wrong?
    ---------------------------------------------
    Sure i got it... what s a form again?

  5. #5
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    If you're using Printer.Print, make sure you use Printer.EndDoc after it, otherwise the printer & the program think there is still more coming.
    Be nice to Harley riders...

  6. #6
    Join Date
    Apr 2001
    Location
    USA
    Posts
    161
    I've been trying to find info how to use this better but I don't find it..
    Yes i knew about the enddoc stuff, I understand how u send text directly to the printer with
    printer.print 'hello world"
    enddoc

    I understand how to print a picture, but i can't get to make this work with pdf.. Would you happen to have a exemple?
    Thank for the help
    ---------------------------------------------
    Sure i got it... what s a form again?

  7. #7
    Join Date
    Apr 2002
    Location
    Melbourne, Victoria, Australia
    Posts
    1,792
    Sorry - I don't have any code for this here or at home - I did this at my last job and it seemed to work fine.
    Be nice to Harley riders...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured