[win32com] Print html

Bill Scherer Bill.Scherer at VerizonWireless.com
Mon Aug 14 09:20:05 EDT 2000


Alex Martelli wrote:

> "Bill Scherer" <Bill.Scherer at VerizonWireless.com> wrote in message
> news:3997DBBF.E727F1DB at VerizonWireless.com...
> > Alex Martelli wrote:
> >
> > > "Bill Scherer" <Bill.Scherer at VerizonWireless.com> wrote in message
> > > news:39945697.F47A13EE at VerizonWireless.com...
> > > > Hello,
> > > >
> > > > I'm looking for a way to automate printing html on win32 with python.
> > > > Currently, I'm able to load IE5 as a com object and get it to load a
> > > > document.
> > > > I can get the document object from the IE5 object.
> > > > Neither object seems to have a print method of any kind.
> > > > Any ideas?
> > >
> > > IWebBrowser2::ExecWB takes as its first parameter the
> > > OLECMDID (numeric code) of the command you want IE to
> > > execute.
> >
> > OK, where does  IWebBrowser2 com from?
>
> It's one of the interfaces implemented by a browser-object.  What you
> call the "IE5 object" should expose this method, among many others.
>
> > This is how I get my handle to IE:
> >     I ran makepy.py for shdocvw.dll
> >     import win32com.client
> >     ie = win32com.client.Dispatch("InternetExplorer.Application.1")
>
> So ie.ExecWB(6,2) should work just fine, I think.

Yup, this works fine.  The only snag I found is that I have to put a small
delay
between the Navigate call and the ExecWB call (time.sleep(1)).

Being IE, this call will print doc files, too.  I expect that should work for
any
file that ie can display via an embedded com server...

Thanks for your help!

--
William K. Scherer
Sr. Member of Applications Staff - Verizon Wireless
Bill.Scherer_at_VerizonWireless.com







More information about the Python-list mailing list