|
-
Mar 20th, 2003, 03:38 PM
#1
Thread Starter
Banned
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
-
Mar 20th, 2003, 03:47 PM
#2
Fanatic Member
Do something like this but wher i have notepad put in your path
VB Code:
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
Const SW_SHOWNORMAL = 1
Private Sub label1_Click()
ShellExecute Me.hwnd, vbNullString, "notepad.exe", vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Private Sub label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
label1.ToolTipText = label1.Caption
End Sub
-
Mar 20th, 2003, 03:49 PM
#3
Thread Starter
Banned
But this isnt a label..its a text box control...
Jon
-
Mar 20th, 2003, 03:49 PM
#4
Thread Starter
Banned
Plus I want to give it the effect of a hyperlink (blue underlined)
Jon
-
Mar 20th, 2003, 03:53 PM
#5
Fanatic Member
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
-
Mar 20th, 2003, 03:55 PM
#6
Thread Starter
Banned
ya you're right sorry bout that...general dumb user error 
Thanks,
Jon
-
Mar 20th, 2003, 03:58 PM
#7
Fanatic Member
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
-
Mar 20th, 2003, 04:08 PM
#8
Thread Starter
Banned
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
-
Mar 20th, 2003, 04:28 PM
#9
Thread Starter
Banned
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
-
Mar 20th, 2003, 04:45 PM
#10
Fanatic Member
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
-
Mar 20th, 2003, 04:46 PM
#11
PowerPoster
DO you have these API constants and calls in your form? Or in a module for that matter?
VB Code:
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
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.

-
Mar 20th, 2003, 05:09 PM
#12
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|