VBA, MS Access MS Access в примерах

Открытие файла программой по умолчанию


Файл поссыллке:

Public Sub WScriptFollowHyperlink(vLink)
' es - 26.03.2022 - LE 22.11.2022 v002
' FollowHyperlink is not working properly !!!
'----------------------------------------------------------------------------------------------
Dim wsShell As Object
Dim sVal As String
On Error GoTo WScriptFollowHyperlink_Err
    
    sVal = vLink & ""
    If Len(sVal) & "" < 5 Then Exit Sub

     sVal = Chr(34) & sVal & Chr(34) 'В двойные кавычки! - на случай пробелов и ...
    'Debug.Print sVal

'Открытие файла программой по умолчанию    
    Set wsShell = CreateObject("WScript.Shell")
    wsShell.Run sVal
    DoEvents

WScriptFollowHyperlink_End:
    On Error Resume Next
    Set wsShell = Nothing
    Err.Clear
    Exit Sub

WScriptFollowHyperlink_Err:
    MsgBox "Cannot open document:" & vbCrLf & vLink & vbCrLf & _
    "Contact database administrator.  Err: " & Err.Number, vbExclamation, "Error!"
    'MsgBox "Error " & Err.Number & " (" & Err.Description & ") in Sub" & _
           "WScriptFollowHyperlink.", vbCritical, "Error!"
    'Debug.Print "WScriptFollowHyperlink_Line: " & Erl & "."
    Err.Clear
    Resume WScriptFollowHyperlink_End
End Sub


Можно так же как и ссылки в Internet:
НО: FollowHyperlink is not working properly !!!
Файл:

Dim strPath As String
'Задаём путь:
    'strPath = "d:\Books\Programming\MS SQL Server\Инструкция по установке MS SQL Server 2008.pdf"
    strPath = Me!txtFPatch & ""
    If Dir(strPath) = "" Then
        MsgBox "Файл не найден!", vbExclamation
        Exit Sub
    End If
'Открытие файла программой по умолчанию
    Application.FollowHyperlink strPath


Вариант со ссылкой:

Dim strURL As String
'Задаём URL:
    strURL = "http://msa.polarcom.ru/"
'Открываем ссылку в браузере по умолчанию
    Application.FollowHyperlink strURL
Назад ToTop
L.E. 25.05.2023
Рейтинг@Mail.ru