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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hyperlink/browse for file 1

Status
Not open for further replies.

Lhuffst

Programmer
Jun 23, 2003
503
0
0
US
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
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
 
>Dim fDialog As Office.FileDialog get error on this line.

Step 1: Is it safe to assume that you have set a reference to the Microsoft Office Object Library?
 
Well duhhh I inadvertently checked microsoft access 14.0 object library instead of microsoft office 14.0 object library. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top