open(.xls file, 'w') so that hyperlinks appear

Steve Holden sholden at holdenweb.com
Tue Nov 13 23:05:30 CET 2001


"Lemniscate" <d_blade8 at hotmail.com> wrote in message
news:7396d2b2.0111131345.22483e62 at posting.google.com...
> Actually, here is the code I am working on now.  Like I said, I am
> tring to learn COM and am, basically, adding methods to the EasyExcel
> example given in the Excel chapter of Programming Python on Win32.
> Here is what the code I am using now.  It uses the same functions and
> methods as the previous code, but uses the proper COM methods to
> create a Excel file and enter data.  The problem I have now, as I
> said, is that I cannot insert hyperlinks.  I believe I posted my
> interactive attempts based on the Excel help files (they should be up
> soon so you can see what I mean).  Anyways, here is my new code (quick
> note:  I was working around the problem by creating html files with
> the links I wanted and inserting them into an Excel sheet.  It
> worked/works but is, like you said, not a python thing, plus it makes
> things a whole lot messier.  I am also in the middle of adding a
> Tkinter GUI interface, as well as converting over to
> win32com.client.Dispatch methods, so the code is really messy).
> Thanks:
>
I mailed a reply to your hotmail address by accident. I'm guessing that's a
write-only mailbox? Here's what I wrote...

Lemniscate wrote ...
> Okay, my other post should be up soon, but I thought I would throw
> this out.  First off, I should say I am not a VB person, so I have to
> work at converting VB code into win32client compatible commands.
> However, the Help File in the MS Excel Help has me stumpted.  Here is
> the page I am using as a basis and afterwards is just a cut and paste
> of my attempts (at an interactive prompt) to insert a hyper link.

I have similar problems myself. Prejudicially, I tend to assume this is
because VBA was designed by immediately-post-college CS students with
little or no feel for programming rightness and no effective supervision.
Feel any better? ;-)

[ tale of woe snipped ]

Does the following help?

>>> from win32com.client import Dispatch
>>> xlApp = Dispatch("Excel.Application")
>>> xlApp.visible = 1
>>> xlApp.Workbooks.Add()
<COMObject Add>
>>> sh = xlApp.Workbooks(1).Sheets(1)
>>> sh.Range("A1").Select()
1
>>> sh.Hyperlinks.Add(sh.Range("A1"),
Address="http://www.holdenweb.com", TextToDisplay="Steve's Web Site")
<COMObject Add>
>>>

Hope so.

you-got-the-web-site-link-above-ly y'rs  - steve


--
http://www.holdenweb.com/








More information about the Python-list mailing list