PDA

View Full Version : Creating a hyperlink



Abdullah
02-20-2008, 02:53 PM
Hi guys,

I have the following line in a VBA Macro...

Set ish = cel.Range.InlineShapes.AddPicture(FileName:=pic.Path, LinkToFile:=False, SaveWithDocument:=True)

Where

Dim ish As InlineShape

The line adds a photo to the a cell in the table. I'm trying to make that photo a hyperlink to the actual photo file (since in the table's cell its only a thumbnail).

I tried changing LinkToFile:=True which didn't work
I also tried setting LinkToFile:=pic.path which also didn't work...it resulted in a Runtime error '4218'....type mismatch

is there an easy adjust to that line to make the thumbnail it inserts into a hyperlink to the actual file?

I know that pic.Name, pic.DateCreated, pic.Size are valid information, pic.path seems to be (it works in the first spot in the code)

Tinbendr
02-20-2008, 03:34 PM
I tried changing LinkToFile:=True which didn't work
Different type of link needed.


Dim MyLink As Hyperlink
Set Ish = cel.Range.InlineShapes.AddPicture(FileName:=Pic.Path, _
LinkToFile:=False, SaveWithDocument:=True)
Set MyLink = ActiveDocument.Range.Hyperlinks.Add(Ish, Pic.Path, , , "Click here")

Abdullah
02-21-2008, 07:04 AM
AWESOME!!!! That worked....thanks a lot Tinbendr, I was banging my head against the wall trying to figure out how to get it to work.

fumei
02-21-2008, 11:30 AM
Underscore character please.

Tinbendr
02-21-2008, 01:08 PM
Underscore character please.It looked fine in preview. :dunno

fumei
02-22-2008, 11:17 AM
"It looked fine in preview."

Say what?????

Looked fine in preview....

Ummmmmm.......let me know when I have a good enough Internet connection that I will be able to see YOUR preview.

"It looked fine in preview."

I have to shake my head on that one.

Tinbendr
02-22-2008, 03:06 PM
I have to shake my head on that one.http://i26.photobucket.com/albums/c147/Tinbendr/Misc/monkey.gif

senthilkumar
02-22-2008, 08:46 PM
:think: Hai Abdullah.

You can do that as I said below.

ActiveDocument.Range.Hyperlinks.Add <Shape object>,<URL>

Ex:
ActiveDocument.Range.Hyperlinks.Add ActiveDocument.InlineShapes(4),"C:\Documents and Settings\senthilkumar\My Documents\My Pictures\deeprangoli.jpg"

Thanks,
S. Senthil Kumar.

fumei
02-24-2008, 06:46 PM
Thanks Tinbendr, that made me laugh.