View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default simply lost on hyperlinks

yep.. I'm here.

My idea never included a commandbutton????... and the code you list is
certainly not mine :(

If you want to have a commandbutton that jumps to a website
sub CommandButton3_Click()
ActiveWorkbook.followHyperlink("http://www.microsoft.som")
end sub


BUT:
your original question was: you wanted hyperlinks where the user couldnt
see or edit the address of the hyperlink.

My solutions was to create bogus hyperlinks
The bogus hyperlink points to itself, so if the user clicks on it
it will jump to itself (do nothing) ... AND trigger a followhyperlink
event.Then use the event handler to redirect 'traffic'


Sub ThisIsJustSomeDummyCodeToQuicklyInsertHyperLinksFo rTesting()
Dim r As Range
For Each r In [a1:a4].Cells
r.Hyperlinks.Add r, "", r.Address, "Tooltip", "ClickMe"
Next
End Sub


Now open the code module for sheet1 (double click Sheet1 in VBE project
explorer. Here we can build the event HANDLER for the followhyperlink
event.


Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
'Based on WHICH HL was clicked we can now go whereever we want.
Select Case Target.Range.Address
Case "$A$1"
ActiveWorkbook.FollowHyperlink ("http://www.microsoft.com")
Case "$A$2"
ActiveWorkbook.FollowHyperlink ("http://www.adobe.com")
Case "$A$3"
ActiveWorkbook.FollowHyperlink ("http://www.google.com")
Case "$A$4"
ActiveWorkbook.FollowHyperlink ("http://www.xlSupport.com")
End Select
End Sub


Capisce?


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


bbxrider wrote:

from earlier post still trying to figure a hyperlink called from a
command button where i dont have to have cell displaying the hyperlink
url, which is bogus anyway because the hyperlink url is being changed
programatically anyway
the basics of what i'm using this was generously suggested keepIt

Cool,
still there keepIt?

Sub ff()
Dim r As Range
Set r = [b3]
r.Hyperlinks.Add r, "", r.Address,"ClickMe"
End Sub

here is what i'm trying

Private Sub CommandButton3_Click()
Dim r As Range
Set r = [o18]
r.Hyperlinks.Add r, "", ivGraphUrl, ""
' ivGraphUrl is a public var that i set

activeworksheet.followhyperlink r

end sub

so the code works in that i get the web page in a new window
but i still get the hyperlink showing in cell 'o18' and not sure why?

and while on the subject.....
no sure about the r.hyperlinks.add syntax

my object browser has this
object.Add(Anchor, Address, SubAddress, ScreenTip, TextToDisplay)

it seems to be saying add a hyperlink to cell 018 twice, once in the
'r.' and secondly the first parameter 'r' ?????
and
i'm really using the sub address instead of the address, they are
interchangeable??

it seems the worksheet has an array of hyperlinks but i'm not adding

the
hl to the sheet array directly but to a cell, there is someway to tell
what member of the hl array is for each cell??