I have a text box on a form that will display a hyperlink that I've created. Clicking on the words will bring up the PDF.
My problem is for a new hyperlink, what is the easiest way for the users to create the hyperlink?
I had to
1. Click in the text box
2. right click mouse
3. select hyperlink
4. select edit hyperlink
5. browse to the file
6. select file and click ok.
That is far to many steps for the general user so I would like to figure out a way to shortcut the steps.
I thought that when I click in the box, I could bring up the dialog box and the user could select the file and click ok to save as a hyperlink.
So far, I haven't had any luck with this part.
I did try this code but get an error
Thanks
lhuffst
My problem is for a new hyperlink, what is the easiest way for the users to create the hyperlink?
I had to
1. Click in the text box
2. right click mouse
3. select hyperlink
4. select edit hyperlink
5. browse to the file
6. select file and click ok.
That is far to many steps for the general user so I would like to figure out a way to shortcut the steps.
I thought that when I click in the box, I could bring up the dialog box and the user could select the file and click ok to save as a hyperlink.
So far, I haven't had any luck with this part.
I did try this code but get an error
Code:
Private Sub cmdPopulateHyperlink_Click()
[highlight #FCE94F]Dim fDialog As Office.FileDialog[/highlight] get error on this line.
Dim varFile As Variant
' Clear listbox contents.
' Me.FileList.RowSource = ""
' Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
'First, set a Reference to the Microsoft Office XX.X Object Library
Dim strButtonCaption As String, strDialogTitle As String
Dim strHyperlinkFile As String
'Define your own Captions if necessary
strButtonCaption = "Save Hyperlink"
strDialogTitle = "Select File to Create Hyperlink to"
With Application.FileDialog(msoFileDialogFilePicker)
With .Filters
.Clear
.Add "All Files", "*.*" 'Allow ALL File types
End With
'The Show Method returns True if 1 or more files are selected
.AllowMultiSelect = False 'Critical Line
.FilterIndex = 1 'Database files
.ButtonName = strButtonCaption
.InitialFileName = vbNullString
.InitialView = msoFileDialogViewDetails 'Detailed View
.Title = strDialogTitle
If .Show Then
For Each varItem In .SelectedItems 'There will only be 1
'Caption and Address of Hyperlink will be the same (Caption#Address)
strHyperlinkFile = varItem & "#" & varItem
Me![Link] = strHyperlinkFile
Next varItem
End If
End With
End Sub
Thanks
lhuffst