ShellExecute -- Printing Error -- Memory Problem ?

Posted on 2006-04-07
Last Modified: 2010-04-07
We are having a problem printing a certain document from Excel when it is shelled from VB6 (most documents print fine). If we run Excel and load the file separately, it prints fine (using Black Ice ColorPlus printer driver). However, launching Excel via ShellExecute causes an error. We aren't sure what is causing it, but the only thing that seems different is that it is run in a shell. It normally works fine, but could this be causing problems?

Function StartDoc(DocName As String) As Long
   Dim Scr_hDC As Long
   Scr_hDC = GetDesktopWindow()
   StartDoc = ShellExecute(Scr_hDC, "Open", DocName, "", "C:\", SW_SHOWNORMAL)

p.s., first part of error message:

Your file could not be printed due to an error on Black Ice ColorPlus on IcePortAD:. There are several possible reasons:
Question by:GivenRandy
    LVL 28

    Accepted Solution

    Do you get the error if you call it like this?

    Function StartDoc(DocName As String) As Long
       Dim Scr_hDC As Long
       Scr_hDC = GetDesktopWindow()
       StartDoc = ShellExecute(0, "Open", DocName, "", "", SW_SHOWNORMAL)
    LVL 9

    Author Comment

    Turns out that their latest driver fixes up. Time for an upgrade!

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now