Results 1 to 12 of 12

Thread: text to hyperlink

  1. #1

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492

    text to hyperlink

    I do some operations including a filecopy to move an excel document from one directory to the users choice. Once done I snatch this filepath so that the user knows where it is. I wanted it to be a hyperlink on my form, that is the path once clicked should go to this excel file.

    I tried:

    Me.txtLink = "#" & blah blah & "#"

    makes this text box a link...in access...
    what about in vb?

    Jon

  2. #2
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    Do something like this but wher i have notepad put in your path

    VB Code:
    1. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    2. Const SW_SHOWNORMAL = 1
    3. Private Sub label1_Click()
    4.  ShellExecute Me.hwnd, vbNullString, "notepad.exe", vbNullString, "C:\", SW_SHOWNORMAL
    5.  
    6. End Sub
    7.  
    8. Private Sub label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    9. label1.ToolTipText = label1.Caption
    10. End Sub

  3. #3

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    But this isnt a label..its a text box control...

    Jon

  4. #4

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    Plus I want to give it the effect of a hyperlink (blue underlined)

    Jon

  5. #5
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    Jon,

    I must be missing something
    Try putting something in your texbox and use some code I said. do it in the clickevent or kepress etc try this first.

    Cheers

  6. #6

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    ya you're right sorry bout that...general dumb user error

    Thanks,

    Jon

  7. #7
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    What I use sometimes is a label with the caption underlined
    do this in the font property box for the label or textbox this give you the appearence of a hyperlink

    you can also change the color


    Cheers

  8. #8

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    Ya got it ... just set the forecolor to blue and underlined the sucka...

    Im beginning to understand this stuff a tad bit better.

    Thanks to this forum and you laser

    Jon

  9. #9

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    Ack laser the click event is not working. I decided to create a little hand so that when the mouse rolls over it it changes to the pointy hand..but I click the link and nothing happens..the click event doesnt even get fired.

    Private Sub txtCalcSheetLink_Click()
    On Error GoTo Err_Handler
    'sub procedure that has a link in the
    'text field to the euro calc sheet

    ShellExecute Me.hwnd, vbNullString, Me.txtFilePath, vbNullString, Me.txtFileName.Text, SW_SHOWNORMAL

    Done:
    Exit Sub

    Err_Handler:
    MsgBox Err.Description, vbCritical, "Error #: " & Err.Number
    Resume Done

    End Sub

    Private Sub txtCalcSheetLink_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
    On Error Resume Next
    If State = vbLeave Then
    With txtCalcSheetLink
    .Drag vbEndDrag
    End With
    End If
    End Sub

    Private Sub txtCalcSheetLink_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    On Error Resume Next
    Me.Image1.Visible = True
    With txtCalcSheetLink
    .DragIcon = Image1.Picture
    .Drag vbBeginDrag
    End With
    End Sub


    Jon

  10. #10
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    Have a look at the code you must have made an error in the click event

    press f8 and step through the code then run it etc

    IT worked before so revert to the old mouse icon first then
    try again

    if it works look where your going wrong

    Sorry I have to go offline

    Good luck

  11. #11
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    DO you have these API constants and calls in your form? Or in a module for that matter?

    VB Code:
    1. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    2. Private Const SW_SHOWNORMAL = 1

    IF you put these in your form put them at the very top of the form above all other code. But remember it will only be available to that form. If you want it to be availiable to all forms then put it in a Module and change Private to Public.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  12. #12
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width