Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert string into a hyperlink

Status
Not open for further replies.

walejo89

Programmer
Jan 28, 2005
43
US
I need to make a string a hyperlink how do i do that using vba
 
This is from Access VBA help.


Code:
Sub CreateHyperlink(ctlSelected As Control, _
     strSubAddress As String, Optional strAddress As String)
    Dim hlk As Hyperlink
    Select Case ctlSelected.ControlType
        Case acLabel, acImage, acCommandButton
            Set hlk = ctlSelected.Hyperlink
            With hlk
                If Not IsMissing(strAddress) Then
                    .Address = strAddress
                Else
                    .Address = ""
                End If
                .SubAddress = strSubAddress
                .Follow
                .Address = ""
                .SubAddress = ""
            End With
        Case Else
            MsgBox "The control '" & ctlSelected.Name _
                 & "' does not support hyperlinks."
    End Select
End Sub

The early bird gets the worm, but the second mouse gets the cheese.
 
Hi fake, what i am trying to do is the following, I have a access form and the access form has a button, when i click this button, i send an email to the people i choose in a list box that I also have in the access form. in the body part of the email I am trying to make the name of the person a hyperlink using vba so when the person gets the email in their mailbox they can click on their name and the monthly report will come up.
WIlfer ANY HELP WILL BE APPRICIATED here is part of the code

strMessage(n) = " IdNumber:" & item12 & Chr(12) & _
Chr(12) & "Salutation:" & item1 & _
Chr(12) & "Name:" & item2 & _
Chr(12) & "PS:" & item3 & _
Chr(12) & "SS:" & item4 & _
Chr(12) & "CPhone:" & item5 & _
Chr(12) & "Phone:" & item6 & _
Chr(12) & "Email:" & item7 & _
Chr(12) & "Attachment:" & item8 & _
Chr(12) & "Rate:" & item9 & _
Chr(12) & "Communication:" & item10 & _
Chr(12) & "Manager:" & item11 & Chr(12) &

'Create new mail message
Set gappOutlook = GetObject(, "Outlook.Application.9")
Set nms = gappOutlook.GetNamespace("MAPI")
Set fld = nms.GetDefaultFolder(olFolderOutbox)

Set msg = fld.Items.Add
With msg
.To = EmailRes
.Subject = strSubject
For m = 0 To p
strBody = strBody & " " & strMessage(m) & Chr(12) & Chr(12)
Next m

.Body = strBody

end with
 
I really don't think you will be able to accomplish this in that fashion because you are sending a basic string to outlook and a string can't have hyperlinks.

I think you will need to control the creation of the message in the Outlook application object. I'm not allowed to have Outlook at my job so i can't help there.

I would as a workaround create the email content in MS Word and use..

Code:
    ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
        "C:\Documents and Settings\rbaker5\Desktop\PhoneList.xls", SubAddress:="" _
        , ScreenTip:="", TextToDisplay:="this_is_a_hyperlink"

then send that.


The early bird gets the worm, but the second mouse gets the cheese.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top