Link to home
Start Free TrialLog in
Avatar of BigBoss
BigBoss

asked on

Printing using ShellExecute without showing the print dialog!

Hello,

Is there any way to print an HTML file using the ShellExecute API but without showing the Windows print dialog?
The ShellExecute will use the associated application (IE) to print the file.
I think that I have read somewhere in MSDN that this is a security issue and that's why the print dialog is shown in IE when printing!
I know how to bypass the print dialog using the web browser control, but I don't want to use the web browser control!

Thank you.
Avatar of BrianGEFF719
BrianGEFF719
Flag of United States of America image

Avatar of [ fanpages ]
[ fanpages ]

Hi,

I haven't tried this suggestion, but suspect it would probably work...

The window handle returned from ShellExecute could be used in the SendMessage API in order to force a [RETURN] code (13) to the print dialog window.

[Like a more sophisticated "SendKeys" :)]

BFN,

fp.
Avatar of BigBoss

ASKER

BrianGEFF719...did you read my question well?????
I said:
>>I know how to bypass the print dialog using the web browser control, but I don't want to use the web browser control!

fanpages...thank you for your comment. This is just a "workaround" and I suspect that it would work!
The ShellExecute does not return a window handle, rather, it returns a success of failure codes!
Can you provide code, please?

Thank you.
Hi,

Sorry, I am confused, "ShellExecute" does return the ProcessID of the invoked executable.

Have you proven otherwise?

BFN,

fp.
Avatar of BigBoss

ASKER

fanpages...the ShellExecute return codes are described in Q170918 of MSDN. It does not return any window handle or ProcessID. Probably, you are confusing it with the Shell function.

Thank you.
Why dont you want to use IE?
You dont have to create a "control" on a form, you can do it purly with code.

-Brian
Oh, yes, I meant to type "ShellExecuteEx".
The SHELLEXECUTEINFO Structure's "Handle" item will contain the "ProcessId" information.

Are you familiar with this API call?

I can provide code if you are not.

BFN,

fp.

Avatar of BigBoss

ASKER

BrianGEFF719...I am not sure if you can do it without at least adding a reference to your project.
In other words, the question is: Can my application load and its other functions work even if the user does not have IE?... thank you.

fanpages, can you please provide code for the specific task?, i.e. for sending a message to the print dialog that is opend by IE through my application (using ShellExecuteEx). And, if another instance(s) of my application (component) opens another print dialog(s) at the same time, would everything work fine???

Thank you.
First, you can use the IE control entierly by reference, secondly, you are asking fanpages for examples to Open IE?? whats that about, any windows computer will work...because they all come with IE....you dont make sense.


-Brian
I resign from this question....good luck.
Avatar of BigBoss

ASKER

BrianGEFF719...thank you for your comment.
What I want to do is to have my application (ActiveX component) to be able to print several types of stuff, including html pages. If the user machine does not have IE installed, I want my component to still function for the other stuff. In addition, if the user machine has another browser, I want the component to be able to print html using that browser.
Now the problem with IE is that if I don't use the browser control to print, but use IE itself, it shows the print dialog, which I don't want.
If I include any references to the browser control or IE itself in my component, as far as I know, it won't load...am I wrong?

I am not sure if the case in clear now!
go to project -> REFERENCES and check off microsoft internet controls


Private WithEvents IEObj As SHDocVw.InternetExplorer

Private Sub Form_Load()
   Set IEObj = New SHDocVw.InternetExplorer
   IEObj.Navigate "c:\yourxmlfile"
End SUb

Private Sub Form_Unload()
   Set IEObj = Nothing
End Sub

Private Sub IEObj_DocumentComplete(...)
   IEObj.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
   Unload Me
End Sub




You do not have to create a control on a form.

-Brian
Avatar of BigBoss

ASKER

Brian...thank you for your comment and for the code.
Are you sure that my compiled component will load on a machine that does not have IE (and shdocvw.dll) installed?
As far as I know, if an application includes a reference that can not be found on the user machine, on load it will popup an error message and will exit!!!
Am I wrong???
I want my other functions in the component to work if the user does not have IE installed.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of BrianGEFF719
BrianGEFF719
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BigBoss

ASKER

Thanks...
Do you need any further help with this issue?

-Brian