Hello, I'm opening a web page and need to print just the first two pages.
Is it possible?
I'm using this code..
IEwindow.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
Hello, I'm opening a web page and need to print just the first two pages.
Is it possible?
I'm using this code..
IEwindow.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
What is IEwindow? You need to get a hold of the Document from the Internet Explorer Application object. Maybe...
Dim htmlDoc as HTMLDocument
Set htmlDoc = ?AppObject?.Document
htmlDoc.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, Null, Null
I have not had much luck bypassing the user prompt. You may be able to bypass when printing vs. saving. I have seen some creative examples to get a hold of the pop up and click the OK control in it.......
I'm using a function to verify the title of the windows of IE and then Print if this is the window that I want to printWhat is IEwindow? You need to get a hold of the Document from the Internet Explorer Application object. Maybe...
Dim htmlDoc as HTMLDocument
Set htmlDoc = ?AppObject?.Document
htmlDoc.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, Null, Null
I have not had much luck bypassing the user prompt. You may be able to bypass when printing vs. saving. I have seen some creative examples to get a hold of the pop up and click the OK control in it.......
Dim allExplorerWindows As New SHDocVw.ShellWindows
Set allExplorerWindows = New SHDocVw.ShellWindows
Dim IEwindow As SHDocVw.InternetExplorer
Dim IEwindow As SHDocVw.InternetExplorer
You can try to print the Window. I have not tried it before. You just need to assign Null to the pvaIn and pvaOut.
IEwindow.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, Null, Null
If that does not work then reference Microsoft Internet Controls and assign an internet explorer object to = Window object
create an Internet explorer object
Dim appInternet As InternetExplorer
Set appInternet = IEwindow.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, Null, Null
Before, I was thinking you needed the Document Object but that is not the case. ExecWB is not within the scop od Document. But you could perhaps use another method to print from Document. It may format better.
But I need to print just the two first pages
I don't know what to say to that. Are you having succes printing? What object are you printing? As I mentioned, creating objects that are better focused on your target may format better.
I'm printing a web page, and printing with success all pages. But again, I need just the first two.
I believe there are ways to interact with printer DLL files to manipulate the printer settings. You would have to do some research on that. My memory is not producing a vivid picture right now. I would approach it by drilling down on the HTML elements I want and extracting those elements from the web page to a String. You may have to write to a text file, save it, and then send the text file to a printer.
I got it. But I solve changing margins numbers. =D
Perhaps you can share your solution here in this thread so others can benefit.
Just change margin number on Page Settings from Internet Explorer Menu