Print Automation with IE7  
Author Message
kevin89065





PostPosted: Thu Nov 08 14:25:29 PST 2007 Top

VB Scripts >> Print Automation with IE7

I'm having a problem automating printing html/web pages with IE7 and I
am wondering if anyone else has had the same problem.

When I print large numbers of html docs or web pages, I am finding
that IE7 is occasionally sending only a single page to the printer.

My sequence is this:

set default printer
while ( files left)
{
open html file
print html, wait for completion
}

I will randomly get a print job that has only a single page; it
contains only the page header / footer information that IE prints and
no contents.

I have been able to duplicate this with IE7 on Vista 64 and on XPSP2.
Has anyone else seen this issue?

Geekgrrl.

Visual Studio198  
 
 
mr_unreliable





PostPosted: Thu Nov 08 14:25:29 PST 2007 Top

VB Scripts >> Print Automation with IE7 GeekGrrl, when you "open" the web page, are you testing
whether the page has finished loading before starting
to print?

Note: the preferred method is to use "ready state":

--- <snip> ---
Const READYSTATE_COMPLETE = 4

Do ' wait until page loaded
WScript.Sleep 10 ' allow for processing events
Loop Until oIE.ReadyState = READYSTATE_COMPLETE
--- </snip> ---

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)





> I'm having a problem automating printing html/web pages with IE7 and I
> am wondering if anyone else has had the same problem.
>
> When I print large numbers of html docs or web pages, I am finding
> that IE7 is occasionally sending only a single page to the printer.
>
> My sequence is this:
>
> set default printer
> while ( files left)
> {
> open html file
> print html, wait for completion
> }
>
> I will randomly get a print job that has only a single page; it
> contains only the page header / footer information that IE prints and
> no contents.
>
> I have been able to duplicate this with IE7 on Vista 64 and on XPSP2.
> Has anyone else seen this issue?
>
> Geekgrrl.
>
 
 
geekgrrl





PostPosted: Thu Nov 08 14:36:49 PST 2007 Top

VB Scripts >> Print Automation with IE7

> GeekGrrl, when you "open" the web page, are you testing
> whether the page has finished loading before starting
> to print?
>
> Note: the preferred method is to use "ready state":
>
> --- <snip> ---
> Const READYSTATE_COMPLETE = 4
>
> Do ' wait until page loaded
> WScript.Sleep 10 ' allow for processing events
> Loop Until oIE.ReadyState = READYSTATE_COMPLETE
> --- </snip> ---
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but,
> no guarantee the answers will be applicable to the questions)
>
>
>

> > I'm having a problem automating printing html/web pages with IE7 and I
> > am wondering if anyone else has had the same problem.
>
> > When I print large numbers of html docs or web pages, I am finding
> > that IE7 is occasionally sending only a single page to the printer.
>
> > My sequence is this:
>
> > set default printer
> > while ( files left)
> > {
> > open html file
> > print html, wait for completion
> > }
>
> > I will randomly get a print job that has only a single page; it
> > contains only the page header / footer information that IE prints and
> > no contents.
>
> > I have been able to duplicate this with IE7 on Vista 64 and on XPSP2.
> > Has anyone else seen this issue?
>
> > Geekgrrl.- Hide quoted text -
>
> - Show quoted text -

Yes, I am, sorry I should have mentioned that.
That is originally what I thought the problem was, but I traced
through the code and the readstate is being changed by IE and I am
waiting on it.

 
 
Paul





PostPosted: Thu Nov 08 21:34:07 PST 2007 Top

VB Scripts >> Print Automation with IE7




>> GeekGrrl, when you "open" the web page, are you testing
>> whether the page has finished loading before starting
>> to print?
>>
>> Note: the preferred method is to use "ready state":
>>
>> --- <snip> ---
>> Const READYSTATE_COMPLETE = 4
>>
>> Do ' wait until page loaded
>> WScript.Sleep 10 ' allow for processing events
>> Loop Until oIE.ReadyState = READYSTATE_COMPLETE
>> --- </snip> ---
>>
>> cheers, jw
>> ____________________________________________________________
>>
>> You got questions? WE GOT ANSWERS!!! ..(but,
>> no guarantee the answers will be applicable to the questions)
>>
>>
>>

>> > I'm having a problem automating printing html/web pages with IE7 and I
>> > am wondering if anyone else has had the same problem.
>>
>> > When I print large numbers of html docs or web pages, I am finding
>> > that IE7 is occasionally sending only a single page to the printer.
>>
>> > My sequence is this:
>>
>> > set default printer
>> > while ( files left)
>> > {
>> > open html file
>> > print html, wait for completion
>> > }
>>
>> > I will randomly get a print job that has only a single page; it
>> > contains only the page header / footer information that IE prints and
>> > no contents.
>>
>> > I have been able to duplicate this with IE7 on Vista 64 and on XPSP2.
>> > Has anyone else seen this issue?
>>
>> > Geekgrrl.- Hide quoted text -
>>
>> - Show quoted text -
>
> Yes, I am, sorry I should have mentioned that.
> That is originally what I thought the problem was, but I traced
> through the code and the readstate is being changed by IE and I am
> waiting on it.

Readystate is handy but not infallible. Some web pages may be redirected
or due to other things seem to get done a number of times before they are
really done loading. I've asked about it before and got some interesting
replies:

http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_frm/thread/d52a56eaf30ce632/43bce42b9d228270?lnk=st&q=%22paul+randall%22+internet+explorer+ready#43bce42b9d228270

I wound up creating the IE object with scriptable events, and used that to
force my script to wait until the web page is really fully loaded. Let me
know if you would like some sample script. Using object events can be
handy.

-Paul Randall


 
 
geekgrrl





PostPosted: Fri Nov 09 07:45:55 PST 2007 Top

VB Scripts >> Print Automation with IE7

>

>
>
>
>
>


> >> GeekGrrl, when you "open" the web page, are you testing
> >> whether the page has finished loading before starting
> >> to print?
>
> >> Note: the preferred method is to use "ready state":
>
> >> --- <snip> ---
> >> Const READYSTATE_COMPLETE = 4
>
> >> Do ' wait until page loaded
> >> WScript.Sleep 10 ' allow for processing events
> >> Loop Until oIE.ReadyState = READYSTATE_COMPLETE
> >> --- </snip> ---
>
> >> cheers, jw
> >> ____________________________________________________________
>
> >> You got questions? WE GOT ANSWERS!!! ..(but,
> >> no guarantee the answers will be applicable to the questions)
>

> >> > I'm having a problem automating printing html/web pages with IE7 and I
> >> > am wondering if anyone else has had the same problem.
>
> >> > When I print large numbers of html docs or web pages, I am finding
> >> > that IE7 is occasionally sending only a single page to the printer.
>
> >> > My sequence is this:
>
> >> > set default printer
> >> > while ( files left)
> >> > {
> >> > open html file
> >> > print html, wait for completion
> >> > }
>
> >> > I will randomly get a print job that has only a single page; it
> >> > contains only the page header / footer information that IE prints and
> >> > no contents.
>
> >> > I have been able to duplicate this with IE7 on Vista 64 and on XPSP2.
> >> > Has anyone else seen this issue?
>
> >> > Geekgrrl.- Hide quoted text -
>
> >> - Show quoted text -
>
> > Yes, I am, sorry I should have mentioned that.
> > That is originally what I thought the problem was, but I traced
> > through the code and the readstate is being changed by IE and I am
> > waiting on it.
>
> Readystate is handy but not infallible. Some web pages may be redirected
> or due to other things seem to get done a number of times before they are
> really done loading. I've asked about it before and got some interesting
> replies:
>
> http://groups.google.com/group/microsoft.public.scripting.vbscript/br...
>
> I wound up creating the IE object with scriptable events, and used that to
> force my script to wait until the web page is really fully loaded. Let me
> know if you would like some sample script. Using object events can be
> handy.
>
> -Paul Randall- Hide quoted text -
>
> - Show quoted text -

Paul,

Thanks for the link and the information. It gives me some avenues to
explorer.

My biggest issue with this is that the above code, on the same test
machines works flawlessly with IE6. I do know that they revamped the
printing in IE7 so perhaps that is what is getting in the way. The
page does print, but all I get is the header/footer and no page
contents.

I've tested this with large (19 pages) and small (2 pages) local html
files as well as web addresses. In my test I am repeatedly navigating
to and printing the same file/web address 20-40 times. The skipping of
the print is a random event; it may happen 5 times out of 20, or 7
times.

Geekgrrl

 
 
mr_unreliable





PostPosted: Fri Nov 09 09:42:17 PST 2007 Top

VB Scripts >> Print Automation with IE7


> My biggest issue with this is that the above code, on the same test
> machines works flawlessly with IE6.

Ah yes. If you are a regular reader of postings here,
you will have seen a number of complaints to the effect
that this-or-that script used to work perfectly in IE6
and now doesn't work in IE7.

You might even call IE7 "the scripter's nemesis". The
usual recommendation is to revert back to IE6, if at all
possible.

There are other ways to "skin-this-cat". For example,
you could use the "Microsoft.XMLHTTP" object to download
your html pages (at least it works for me). There are
several examples of how to use "Microsoft.XMLHTTP" to
be found in this ng. Use google advanced group search
to find them.

You could also use something else to print them.
Firefox works. Also, you can load-and-print with microsoft
excel -- while XL doesn't render as nicely as IE, it does
work (at least with XL2K).

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)

 
 
mr_unreliable





PostPosted: Fri Nov 09 09:48:46 PST 2007 Top

VB Scripts >> Print Automation with IE7
> You could also use something else to print them.
> Firefox works. Also, you can load-and-print with microsoft
> excel -- while XL doesn't render as nicely as IE, it does
> work (at least with XL2K).
>

Sorry, I meant microsoft _WORD_ can load and print html.

cheers, jw
 
 
Paul





PostPosted: Fri Nov 09 09:45:53 PST 2007 Top

VB Scripts >> Print Automation with IE7




>>

>>
>>
>>
>>
>>


>> >> GeekGrrl, when you "open" the web page, are you testing
>> >> whether the page has finished loading before starting
>> >> to print?
>>
>> >> Note: the preferred method is to use "ready state":
>>
>> >> --- <snip> ---
>> >> Const READYSTATE_COMPLETE = 4
>>
>> >> Do ' wait until page loaded
>> >> WScript.Sleep 10 ' allow for processing events
>> >> Loop Until oIE.ReadyState = READYSTATE_COMPLETE
>> >> --- </snip> ---
>>
>> >> cheers, jw
>> >> ____________________________________________________________
>>
>> >> You got questions? WE GOT ANSWERS!!! ..(but,
>> >> no guarantee the answers will be applicable to the questions)
>>

>> >> > I'm having a problem automating printing html/web pages with IE7 and
>> >> > I
>> >> > am wondering if anyone else has had the same problem.
>>
>> >> > When I print large numbers of html docs or web pages, I am finding
>> >> > that IE7 is occasionally sending only a single page to the printer.
>>
>> >> > My sequence is this:
>>
>> >> > set default printer
>> >> > while ( files left)
>> >> > {
>> >> > open html file
>> >> > print html, wait for completion
>> >> > }
>>
>> >> > I will randomly get a print job that has only a single page; it
>> >> > contains only the page header / footer information that IE prints
>> >> > and
>> >> > no contents.
>>
>> >> > I have been able to duplicate this with IE7 on Vista 64 and on
>> >> > XPSP2.
>> >> > Has anyone else seen this issue?
>>
>> >> > Geekgrrl.- Hide quoted text -
>>
>> >> - Show quoted text -
>>
>> > Yes, I am, sorry I should have mentioned that.
>> > That is originally what I thought the problem was, but I traced
>> > through the code and the readstate is being changed by IE and I am
>> > waiting on it.
>>
>> Readystate is handy but not infallible. Some web pages may be
>> redirected
>> or due to other things seem to get done a number of times before they are
>> really done loading. I've asked about it before and got some interesting
>> replies:
>>
>> http://groups.google.com/group/microsoft.public.scripting.vbscript/br...
>>
>> I wound up creating the IE object with scriptable events, and used that
>> to
>> force my script to wait until the web page is really fully loaded. Let
>> me
>> know if you would like some sample script. Using object events can be
>> handy.
>>
>> -Paul Randall- Hide quoted text -
>>
>> - Show quoted text -
>
> Paul,
>
> Thanks for the link and the information. It gives me some avenues to
> explorer.
>
> My biggest issue with this is that the above code, on the same test
> machines works flawlessly with IE6. I do know that they revamped the
> printing in IE7 so perhaps that is what is getting in the way. The
> page does print, but all I get is the header/footer and no page
> contents.
>
> I've tested this with large (19 pages) and small (2 pages) local html
> files as well as web addresses. In my test I am repeatedly navigating
> to and printing the same file/web address 20-40 times. The skipping of
> the print is a random event; it may happen 5 times out of 20, or 7
> times.
>
> Geekgrrl

Hi
The IE6/IE7 thing is a big clue. With this info, I doubt that my reference
will be of any help to you. I have avoided IE7 on my WXP systems because of
the reports I've seen that it acts differently from IE6, so I have little
experience with it.

Perhaps you could write a minimal script with the problematic URL to
demonstrate the problem. If you would like to play with the
DocumentComplete event, here is what I do:

1) define bDocDone in the main routine. It has to be known globally because
you cannot pass it to the event routine sub E_oIE_DocumentComplete.

2) Create the IE object with event handling capability (with my createobject
satement, subroutines whose name starts with E_oIE_ are executed when the
corresponding event occurs; the rest of the subroutine name must be the
exact name of the event):
Set oIE = WScript.CreateObject("InternetExplorer.Application", "E_oIE_")

3) Use a subroutine to navigate to the ULR and then wait two seconds (I
don't know why I picked two seconds):
NavWaitD oIE, sMainURL
Wscript.Sleep 2000

4) Here is the subroutine to navigate and wait for the browser's
DocumentComplete event to be fired:
Sub NavWaitD(oIE, sURL)
bDocDone = False
oIE.Navigate sURL
Do Until bDocDone: wscript.sleep 100: Loop
End Sub

5) And here is the event routine that indicates the document is done; this
subroutine is called (by the operating system?) which passes the two
arguments to it, when the DocumentComplete event fires for the browser
created above:
sub E_oIE_DocumentComplete(objBrowser, strURL)
'MSDN Info on DocumentComplete Event
' Private Sub object_DocumentComplete( _
' ByVal pDisp As Object, _
' ByVal URL As Variant)
bDocDone = True
End Sub

If you decide to modify the event handling routine:
There should be a minimum of code in an event handling routine. Events come
fast and furiously. A message box, or write to a file within the handler
can mess it up or slow it down so that other events can be missed.

You might modify item 4) above to see how many loops after Readystate
indicates done before bDocDone indicates done. Here you can log things to a
file or display a message box to show what is happening.

-Paul Randall


 
 
geekgrrl





PostPosted: Mon Nov 12 14:37:35 PST 2007 Top

VB Scripts >> Print Automation with IE7

>

>
>
>
>
>


> >> GeekGrrl, when you "open" the web page, are you testing
> >> whether the page has finished loading before starting
> >> to print?
>
> >> Note: the preferred method is to use "ready state":
>
> >> --- <snip> ---
> >> Const READYSTATE_COMPLETE = 4
>
> >> Do ' wait until page loaded
> >> WScript.Sleep 10 ' allow for processing events
> >> Loop Until oIE.ReadyState = READYSTATE_COMPLETE
> >> --- </snip> ---
>
> >> cheers, jw
> >> ____________________________________________________________
>
> >> You got questions? WE GOT ANSWERS!!! ..(but,
> >> no guarantee the answers will be applicable to the questions)
>

> >> > I'm having a problem automating printing html/web pages with IE7 and I
> >> > am wondering if anyone else has had the same problem.
>
> >> > When I print large numbers of html docs or web pages, I am finding
> >> > that IE7 is occasionally sending only a single page to the printer.
>
> >> > My sequence is this:
>
> >> > set default printer
> >> > while ( files left)
> >> > {
> >> > open html file
> >> > print html, wait for completion
> >> > }
>
> >> > I will randomly get a print job that has only a single page; it
> >> > contains only the page header / footer information that IE prints and
> >> > no contents.
>
> >> > I have been able to duplicate this with IE7 on Vista 64 and on XPSP2.
> >> > Has anyone else seen this issue?
>
> >> > Geekgrrl.- Hide quoted text -
>
> >> - Show quoted text -
>
> > Yes, I am, sorry I should have mentioned that.
> > That is originally what I thought the problem was, but I traced
> > through the code and the readstate is being changed by IE and I am
> > waiting on it.
>
> Readystate is handy but not infallible. Some web pages may be redirected
> or due to other things seem to get done a number of times before they are
> really done loading. I've asked about it before and got some interesting
> replies:
>
> http://groups.google.com/group/microsoft.public.scripting.vbscript/br...
>
> I wound up creating the IE object with scriptable events, and used that to
> force my script to wait until the web page is really fully loaded. Let me
> know if you would like some sample script. Using object events can be
> handy.
>
> -Paul Randall- Hide quoted text -
>
> - Show quoted text -

Paul,

Thanks for the link. There's some interesting information there that
I'm going to look into.

I'm actually not using vb script but MFC OLE/COM, but thought I would
post my question here as you can do the same thing in vb script.
The strange thing here is that the same code works flawlessly in IE6,
on all my test machines.

I've run my tests with both large(19 pages) and small(2pages) html
files on disk and actual web addresses, and I'm printing each file
20-40 times in batches.

I know IE7 has made a lot of changes to the underlying printing from
the previous versions of the browser, I'm just wondering if there
isn't a subtle problem with the print templates, as I do get the
header information, just no page contents.

Geekgrrl




 
 
Paul





PostPosted: Mon Nov 12 14:56:56 PST 2007 Top

VB Scripts >> Print Automation with IE7




>>

>>
>>
>>
>>
>>


>> >> GeekGrrl, when you "open" the web page, are you testing
>> >> whether the page has finished loading before starting
>> >> to print?
>>
>> >> Note: the preferred method is to use "ready state":
>>
>> >> --- <snip> ---
>> >> Const READYSTATE_COMPLETE = 4
>>
>> >> Do ' wait until page loaded
>> >> WScript.Sleep 10 ' allow for processing events
>> >> Loop Until oIE.ReadyState = READYSTATE_COMPLETE
>> >> --- </snip> ---
>>
>> >> cheers, jw
>> >> ____________________________________________________________
>>
>> >> You got questions? WE GOT ANSWERS!!! ..(but,
>> >> no guarantee the answers will be applicable to the questions)
>>

>> >> > I'm having a problem automating printing html/web pages with IE7 and
>> >> > I
>> >> > am wondering if anyone else has had the same problem.
>>
>> >> > When I print large numbers of html docs or web pages, I am finding
>> >> > that IE7 is occasionally sending only a single page to the printer.
>>
>> >> > My sequence is this:
>>
>> >> > set default printer
>> >> > while ( files left)
>> >> > {
>> >> > open html file
>> >> > print html, wait for completion
>> >> > }
>>
>> >> > I will randomly get a print job that has only a single page; it
>> >> > contains only the page header / footer information that IE prints
>> >> > and
>> >> > no contents.
>>
>> >> > I have been able to duplicate this with IE7 on Vista 64 and on
>> >> > XPSP2.
>> >> > Has anyone else seen this issue?
>>
>> >> > Geekgrrl.- Hide quoted text -
>>
>> >> - Show quoted text -
>>
>> > Yes, I am, sorry I should have mentioned that.
>> > That is originally what I thought the problem was, but I traced
>> > through the code and the readstate is being changed by IE and I am
>> > waiting on it.
>>
>> Readystate is handy but not infallible. Some web pages may be
>> redirected
>> or due to other things seem to get done a number of times before they are
>> really done loading. I've asked about it before and got some interesting
>> replies:
>>
>> http://groups.google.com/group/microsoft.public.scripting.vbscript/br...
>>
>> I wound up creating the IE object with scriptable events, and used that
>> to
>> force my script to wait until the web page is really fully loaded. Let
>> me
>> know if you would like some sample script. Using object events can be
>> handy.
>>
>> -Paul Randall- Hide quoted text -
>>
>> - Show quoted text -
>
> Paul,
>
> Thanks for the link. There's some interesting information there that
> I'm going to look into.
>
> I'm actually not using vb script but MFC OLE/COM, but thought I would
> post my question here as you can do the same thing in vb script.
> The strange thing here is that the same code works flawlessly in IE6,
> on all my test machines.
>
> I've run my tests with both large(19 pages) and small(2pages) html
> files on disk and actual web addresses, and I'm printing each file
> 20-40 times in batches.
>
> I know IE7 has made a lot of changes to the underlying printing from
> the previous versions of the browser, I'm just wondering if there
> isn't a subtle problem with the print templates, as I do get the
> header information, just no page contents.
>
> Geekgrrl

Hi,
I don't use MFC OLE/COM, so I can't help you there.

Could you modify your program to scroll to the end of the web page prior to
printing, and maybe beep so that you could visually verify that the end
looks correct when the printing starts?

Maybe you have already done this, but one other thing you might do is set it
up to print to a virtual printer so testing doesn't use any trees :-)

-Paul Randall


 
 
geekgrrl





PostPosted: Tue Nov 13 12:05:05 PST 2007 Top

VB Scripts >> Print Automation with IE7

>

>
>
>
>
>


>

>


> >> >> GeekGrrl, when you "open" the web page, are you testing
> >> >> whether the page has finished loading before starting
> >> >> to print?
>
> >> >> Note: the preferred method is to use "ready state":
>
> >> >> --- <snip> ---
> >> >> Const READYSTATE_COMPLETE = 4
>
> >> >> Do ' wait until page loaded
> >> >> WScript.Sleep 10 ' allow for processing events
> >> >> Loop Until oIE.ReadyState = READYSTATE_COMPLETE
> >> >> --- </snip> ---
>
> >> >> cheers, jw
> >> >> ____________________________________________________________
>
> >> >> You got questions? WE GOT ANSWERS!!! ..(but,
> >> >> no guarantee the answers will be applicable to the questions)
>

> >> >> > I'm having a problem automating printing html/web pages with IE7 and
> >> >> > I
> >> >> > am wondering if anyone else has had the same problem.
>
> >> >> > When I print large numbers of html docs or web pages, I am finding
> >> >> > that IE7 is occasionally sending only a single page to the printer.
>
> >> >> > My sequence is this:
>
> >> >> > set default printer
> >> >> > while ( files left)
> >> >> > {
> >> >> > open html file
> >> >> > print html, wait for completion
> >> >> > }
>
> >> >> > I will randomly get a print job that has only a single page; it
> >> >> > contains only the page header / footer information that IE prints
> >> >> > and
> >> >> > no contents.
>
> >> >> > I have been able to duplicate this with IE7 on Vista 64 and on
> >> >> > XPSP2.
> >> >> > Has anyone else seen this issue?
>
> >> >> > Geekgrrl.- Hide quoted text -
>
> >> >> - Show quoted text -
>
> >> > Yes, I am, sorry I should have mentioned that.
> >> > That is originally what I thought the problem was, but I traced
> >> > through the code and the readstate is being changed by IE and I am
> >> > waiting on it.
>
> >> Readystate is handy but not infallible. Some web pages may be
> >> redirected
> >> or due to other things seem to get done a number of times before they are
> >> really done loading. I've asked about it before and got some interesting
> >> replies:
>
> >>http://groups.google.com/group/microsoft.public.scripting.vbscript/br...
>
> >> I wound up creating the IE object with scriptable events, and used that
> >> to
> >> force my script to wait until the web page is really fully loaded. Let
> >> me
> >> know if you would like some sample script. Using object events can be
> >> handy.
>
> >> -Paul Randall- Hide quoted text -
>
> >> - Show quoted text -
>
> > Paul,
>
> > Thanks for the link. There's some interesting information there that
> > I'm going to look into.
>
> > I'm actually not using vb script but MFC OLE/COM, but thought I would
> > post my question here as you can do the same thing in vb script.
> > The strange thing here is that the same code works flawlessly in IE6,
> > on all my test machines.
>
> > I've run my tests with both large(19 pages) and small(2pages) html
> > files on disk and actual web addresses, and I'm printing each file
> > 20-40 times in batches.
>
> > I know IE7 has made a lot of changes to the underlying printing from
> > the previous versions of the browser, I'm just wondering if there
> > isn't a subtle problem with the print templates, as I do get the
> > header information, just no page contents.
>
> > Geekgrrl
>
> Hi,
> I don't use MFC OLE/COM, so I can't help you there.
>
> Could you modify your program to scroll to the end of the web page prior to
> printing, and maybe beep so that you could visually verify that the end
> looks correct when the printing starts?
>
> Maybe you have already done this, but one other thing you might do is set it
> up to print to a virtual printer so testing doesn't use any trees :-)
>
> -Paul Randall- Hide quoted text -
>
> - Show quoted text -

Paul,

I am using a virtual printer already :D, I am actually testing batch
printing to this printer, and of course it all has to be silent and
hidden.

I've added an extra wait check with the Application.Busy flag, and in
preliminary testing seems to be stable but I've got to hammer on it
for a while yet until I'm satisfied.

Thanks for all the feedback.

Geekgrrl


 
 
Paul





PostPosted: Tue Nov 13 12:54:09 PST 2007 Top

VB Scripts >> Print Automation with IE7




>>

>>
>>
>>
>>
>>


>>

>>
>> >> > On Nov 8, 5:25 pm, mr_unreliable


>> >> >> GeekGrrl, when you "open" the web page, are you testing
>> >> >> whether the page has finished loading before starting
>> >> >> to print?
>>
>> >> >> Note: the preferred method is to use "ready state":
>>
>> >> >> --- <snip> ---
>> >> >> Const READYSTATE_COMPLETE = 4
>>
>> >> >> Do ' wait until page loaded
>> >> >> WScript.Sleep 10 ' allow for processing events
>> >> >> Loop Until oIE.ReadyState = READYSTATE_COMPLETE
>> >> >> --- </snip> ---
>>
>> >> >> cheers, jw
>> >> >> ____________________________________________________________
>>
>> >> >> You got questions? WE GOT ANSWERS!!! ..(but,
>> >> >> no guarantee the answers will be applicable to the questions)
>>

>> >> >> > I'm having a problem automating printing html/web pages with IE7
>> >> >> > and
>> >> >> > I
>> >> >> > am wondering if anyone else has had the same problem.
>>
>> >> >> > When I print large numbers of html docs or web pages, I am
>> >> >> > finding
>> >> >> > that IE7 is occasionally sending only a single page to the
>> >> >> > printer.
>>
>> >> >> > My sequence is this:
>>
>> >> >> > set default printer
>> >> >> > while ( files left)
>> >> >> > {
>> >> >> > open html file
>> >> >> > print html, wait for completion
>> >> >> > }
>>
>> >> >> > I will randomly get a print job that has only a single page; it
>> >> >> > contains only the page header / footer information that IE prints
>> >> >> > and
>> >> >> > no contents.
>>
>> >> >> > I have been able to duplicate this with IE7 on Vista 64 and on
>> >> >> > XPSP2.
>> >> >> > Has anyone else seen this issue?
>>
>> >> >> > Geekgrrl.- Hide quoted text -
>>
>> >> >> - Show quoted text -
>>
>> >> > Yes, I am, sorry I should have mentioned that.
>> >> > That is originally what I thought the problem was, but I traced
>> >> > through the code and the readstate is being changed by IE and I am
>> >> > waiting on it.
>>
>> >> Readystate is handy but not infallible. Some web pages may be
>> >> redirected
>> >> or due to other things seem to get done a number of times before they
>> >> are
>> >> really done loading. I've asked about it before and got some
>> >> interesting
>> >> replies:
>>
>> >>http://groups.google.com/group/microsoft.public.scripting.vbscript/br...
>>
>> >> I wound up creating the IE object with scriptable events, and used
>> >> that
>> >> to
>> >> force my script to wait until the web page is really fully loaded.
>> >> Let
>> >> me
>> >> know if you would like some sample script. Using object events can be
>> >> handy.
>>
>> >> -Paul Randall- Hide quoted text -
>>
>> >> - Show quoted text -
>>
>> > Paul,
>>
>> > Thanks for the link. There's some interesting information there that
>> > I'm going to look into.
>>
>> > I'm actually not using vb script but MFC OLE/COM, but thought I would
>> > post my question here as you can do the same thing in vb script.
>> > The strange thing here is that the same code works flawlessly in IE6,
>> > on all my test machines.
>>
>> > I've run my tests with both large(19 pages) and small(2pages) html
>> > files on disk and actual web addresses, and I'm printing each file
>> > 20-40 times in batches.
>>
>> > I know IE7 has made a lot of changes to the underlying printing from
>> > the previous versions of the browser, I'm just wondering if there
>> > isn't a subtle problem with the print templates, as I do get the
>> > header information, just no page contents.
>>
>> > Geekgrrl
>>
>> Hi,
>> I don't use MFC OLE/COM, so I can't help you there.
>>
>> Could you modify your program to scroll to the end of the web page prior
>> to
>> printing, and maybe beep so that you could visually verify that the end
>> looks correct when the printing starts?
>>
>> Maybe you have already done this, but one other thing you might do is set
>> it
>> up to print to a virtual printer so testing doesn't use any trees :-)
>>
>> -Paul Randall- Hide quoted text -
>>
>> - Show quoted text -
>
> Paul,
>
> I am using a virtual printer already :D, I am actually testing batch
> printing to this printer, and of course it all has to be silent and
> hidden.
>
> I've added an extra wait check with the Application.Busy flag, and in
> preliminary testing seems to be stable but I've got to hammer on it
> for a while yet until I'm satisfied.
>
> Thanks for all the feedback.

Geekgrrl,

You are welcome. I'm glad to hear you are making progress.

-Paul Randall