Hi guys, here is one that I have been slamming my head against the wall over for way too long:
I have a .dll which sets the default printer for the server that it is running on. It then opens an instance of IE and navigates to a page which builds an xml file and saves it. That .asp page then redirects to another .asp page which applies a stylesheet to the aforementioned xml file and finally prints it out to the printer which the user selected.
When I set the .dll up on COM+, it alters the default printer, instantiates IE, creates the XML, and then hangs.
When I don't run the .dll in COM+, but instead register the .dll and reference it in my .asp project, it doesn't even get the printer changed.
User intervention isn't always a bad thing, especially when it comes to things like printing. Why change the printer? Maybe the already selected default printer is what the user wants.
Long story made short...the requirement on this product is that the user will not interact with the Printer Settings dialog box. They will simply choose what and where on the web page.
Well, this has taken a change, and I am lost. I basically have everything wrapped up into a COM+ component. The component builds and saves an html file (which is the output of applying an XSL to the XML).
The problem, which has to have an answer, is that I need to be able to say where I want the html file to be printed at. Think about this -- we can have a window with .html files in it, and our printer window open at the same time...grab an .html file and drag and drop on the printer we want and windows knows what to do. This leads one to believe that we should be able to accomplish the same thing through API calls. Does anyone have a clue?
Good thought, but too unstable for our production environment. This application is going to run at the server, so changing the default printer is not an option. I already explored that route.
Again though, good thought, if it was running from the client's PC, that would work.
I found what I was looking for, but it wasn't what I was looking for...
I figured out how to emulate a drag and drop of an .html file onto a printer. However, the real problem remains...I don't want the printer settings message box to pop-up. I've seen people post, saying that this can't be done; however, it can.
You can use the ExecWB function and pass it parameters of (6,6) and it will print with out prompting. I need the best of both worlds, I need to be able to print in automation (without being prompted), to a location which can change on the fly.
Seems to me that it sucks that I can do A or B, but not A & B.
j - quick question for you: If I could show you how to show the printer dialog box, and change anything you want (programatically, of course) would this be an option for you?
Let me know. If it is I'll go ahead and make a sample project for you.
No, the printer will vary. I will always have the printer name. This will be running in a COM+ object on a server, so, it will not necessarily always have the same number of printers installed. The number might change
O.K, I think we are getting somewhere, and I hope we don't dead-end now. So, when I go to print my document, the system produces a print dialog box (I don't). How do I get a handle on it?
Something I tried:
dim prnDialog as PrinterDlg
dim sws as new ShellWindows
for each prnDialog in sws 'there should only be one
next
I registered the prndialog.dll and setup a project reference, then in code right after the print dialog box is raised by the system, the code that runs is the for loop above. The problem now, is that I can't even get into the for loop, I get a "Type Mismatch" error pointing to the for line.
O.K., we're getting somewhere...I think. I can get a handle on the printer dialog box with the GetForegroundWindow() call. Does anyone know how I can set my printer dialog reference equal to the returned handle?
I have been building off of this post onto a different post which seems to address the direction I was going here. Please read this post to continue to assist.
jewell I thought you were trying to print a document with a specific printer that you'd have the name of. I thought I'd answered your question but I guess not - what exactly are you trying to do now?
...does Crystal expose the properties of the printer settings to us programatically to manipulate? The report is going to run in a web browser, in order to render the report, and then the print is kicked off from ie -- but Crystal can alter the print settings at that point in time.
Why can't we do the same?
[Pseudocode]
dim prnDlg as PrinterDlg
set prnDlg = the printer dialog that ie opened
[/Pseudocode]