VBA: Following Hyperlink that's linked to Sharepoint?

Peter h

Active Member
Joined
Dec 8, 2015
Messages
409
I've got a list of Hyperlinks, that are all files on a sharepoint site. When I click on one, it opens Microsoft Edge and at the bottom asks if I want to open the file. When I click "Open", the file then opens in the appropriate desktop app. I'm wondering if there is a way around Microsoft Edge always asking if I want to open the file.

I'm building a File Search Userform that allows me to search and then open the selected file, but it is pretty inconvenient to have to click "Open" ever time I try to open something. Here is what I've got so far:

Code:
Private Sub btn_OpenFile_Click()
    
    Dim currWKB         As Workbook
    Dim fWKS            As Worksheet
    Dim fCell           As Range
    
    Dim fNAME           As String
    
    Set currWKB = ThisWorkbook
    Set fWKS = currWKB.Sheets(1)
    
    If Me.lb_Files.Text = "" Then
        MsgBox "Please select a file from the List Box that you'd like to open.", vbOKOnly
        Exit Sub
    Else
        fNAME = Me.lb_Files.Text
        Set fCell = fWKS.Columns(1).Find(What:=fNAME, LookIn:=xlValues, _
                    SearchOrder:=xlByColumns, SearchDirection:=xlNext)
                    
        fCell.Hyperlinks(1).Follow
        
        currWKB.Activate
        
        If MsgBox(fNAME & " has been opened. Would you like to close the ""Sharepoint Search"" Workbook?" _
                & vbNewLine & vbNewLine & "Clicking No, will keep this file open in the background.", vbYesNo) = vbYes Then
                
            currWKB.Save
            currWKB.Close
        Else
            currWKB.Windows(1).WindowState = xlMinimized
        End If
    End If
End Sub
 

Some videos you may like

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Watch MrExcel Video

Forum statistics

Threads
1,090,006
Messages
5,411,785
Members
403,398
Latest member
casom

This Week's Hot Topics

Top