Programatically Creating a Hyperlink Using VB.Net ?

  • Thread starter Thread starter eBob.com
  • Start date Start date
E

eBob.com

I am going nuts trying to create a spreadsheet using VB.Net. It all
seems to work EXCEPT for a column which has to contain a hyperlink.
I've spent more than 6 hours researching this but just haven't found
the right incantation. Here's the VB.Net code which puts a row of
data to Excel ...

astrRow(0) = oc.name
astrRow(1) = oc.tel
astrRow(2) = oc.tel2
astrRow(3) = oc.age
astrRow(4) = oc.mts
astrRow(5) = "=HYPERLINK(""" & oc.PhotoUrl & """)"
'astrRow(5) = oc.PhotoUrl
'astrRow(5) = "=HYPERLINK(""" & oc.PhotoUrl & """,""" &
oc.PhotoUrl & """)"
XLRow += 1
objSheet.Range("A" & XLRow.ToString, "F" &
XLRow.ToString).Value = astrRow

What I see in column F of the spreadsheet is ...

=HYPERLINK("http://www.confidentialwebsite.com/s_01.jpg")

Clicking on one of these cells generally does nothing. Sometimes if I
make a trivial editing change to one of these cells then Excel will
display the cell as a hyperlink but it is still unable to actually
follow the link.

PLEASE ... if you can help me resolve this I would sure appreciate it.

Thanks, Bob
 
Well ... after further butting of my head against the brick wall, the
wall finally crumbled. The trick was to use objSheet.Range().Formula
instead of objSheet.Range().Value.

I found the answer in VBA doc when that seemed to be the only place I
hadn't looked. I have no idea if it valid, in general, to use VBA
methods in VB.Net, but this Formula method seems to work.

Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top