How to Convert File Path to Hyperlink in MS Access VBA

Hello in this article, you will learn how to convert the file path into a hyperlink using Microsoft Access VBA. Here, we will demonstrate how to use a command button to select a file and then return the file path. Then we will convert the file path into a hyperlink. Below is the table that I use in this example. We will store the path of the map in the “map_path” column as a hyperlink. And then, when we click the hyperlink, it will open the file.

Here is the form

Before we get into the code, we need to enable or add the Microsoft Office 16.0 Object Library (I am using MS Office 365).

Private Sub cmd_open_path_Click()
Dim fdialog As Office.FileDialog
Dim FileLink As Variant

Set fdialog = Application.FileDialog(msoFileDialogFilePicker)
With fdialog
    .AllowMultiSelect = False
    .Filters.Clear
    .Filters.Add "Image File", "*.JPG"
    If .Show = True Then
        FileLink = fdialog.SelectedItems(1)
        Me.map_path.IsHyperlink = True
        Me.map_path = FileLink & "#" & FileLink
    End If
End With
End Sub

Now it’s time to try.

Be the first to comment

Leave a Reply