none
Getting rid of "Some files can contain viruses or otherwise be harmful to your computer." message while opening up a file through MS ACCESS. RRS feed

  • Question

  • So... I have been searching this issue for a bit and all I see are registry fixes online. Any way to use VBA to ignore this message? 

    This is how I'm using it:

    Application.FollowHyperlink "P:\Orlando\Nurse Analyst\DO_NOT_OPEN_BACKEND\OUTLOOK DISTRIBUTION TEMPLATES\VAD.msg"

    Monday, September 16, 2019 4:23 PM

Answers

  • Yeap...this solves the problem

    #If VBA7 Then
    Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
        ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
        Private Declare PtrSafe Function GetDesktopWindow Lib "USER32" () As Long
    #Else
    Private Declare Function GetDesktopWindow Lib "USER32" () As Long
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
        ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    #End If
    Function StartDoc(DocName As String) As Long
          Dim Scr_hDC As Long
          Scr_hDC = GetDesktopWindow
          StartDoc = ShellExecute(Scr_hDC, "Open", DocName, _
          "", "C:\", SW_SHOWNORMAL)
     End Function

    Private Sub Command1_Click()
    Dim e As Long
    e = StartDoc("C:\Temp\Test.msg")
    End Sub

    • Marked as answer by InnVis Tuesday, September 17, 2019 1:56 PM
    Tuesday, September 17, 2019 1:27 PM

All replies

  • One of the easiest fixes is to replace FollowHyperLink with http://allenbrowne.com/func-GoHyperlink.html

    Daniel Pineault, 2010-2019 Microsoft MVP
    Professional Support: http://www.cardaconsultants.com
    MS Access Tips and Code Samples: http://www.devhut.net

    Monday, September 16, 2019 4:32 PM
  • Tried this function, still gives me the warning.

    This is how I called it:

    Call GoHyperlink("P:\Orlando\Nurse Analyst\DO_NOT_OPEN_BACKEND\OUTLOOK DISTRIBUTION TEMPLATES\VAD.msg")


    • Edited by InnVis Monday, September 16, 2019 4:58 PM
    Monday, September 16, 2019 4:58 PM
  • Check if this helps  :  https://support.microsoft.com/en-us/help/925757/how-to-enable-or-disable-hyperlink-warning-messages-in-2007-office-pro
    Monday, September 16, 2019 5:43 PM
  • Hey John, thanks for the link. I looked through this before, but I'm unable to alter the registry in my organization. I was hoping to code something that would just click okay automatically or ignore the warning all together.
    Monday, September 16, 2019 7:54 PM
  • Its a long shot but maybe you could write an AutoIt script and had it execute via Access..this should pickup the Messagebox and press the OK.....the problem with the Messageboxes is that they are modal and all code execution is suspended until clicked...

    Start with this : https://www.autoitscript.com/forum/topic/144880-run-autoit-from-vba-ms-access/

    and this for running AutoIt in the background..

    https://www.autoitscript.com/forum/topic/88332-make-the-script-run-in-background/

    but of course this will require an executable file to be added..... (permitted ?)

    Tuesday, September 17, 2019 12:03 PM
  • Well it seems as i am getting older i tend to forget... :) 

    This will open the file without warning as long as you have set  a default application that opens the file

    #If VBA7 Then
    Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
        ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
        Private Declare PtrSafe Function GetDesktopWindow Lib "USER32" () As LongPtr
    #Else
    Private Declare Function GetDesktopWindow Lib "USER32" () As Long
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
        ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    #End If
    Function StartDoc(DocName As String) As Long
          Dim Scr_hDC As Long
          Scr_hDC = GetDesktopWindow
          StartDoc = ShellExecute(Scr_hDC, "Open", DocName, _
          "", "C:\", SW_SHOWNORMAL)
     End Function

    Private Sub Command1_Click()
    Dim e As Long
    e = StartDoc("C:\Temp\Test.msg")
    End Sub

    The funny part is that i use such technique (or similar) on one of my applications but i totally forgot it 

    I got the code from here : https://stackoverflow.com/questions/18921168/how-can-excel-vba-open-file-using-default-application

    P.S. i haven't tested if for 64bit as i don't have one handy...maybe you need to make some adjustments...


    Tuesday, September 17, 2019 12:18 PM
  • hrmmmmm, I declared the function PtrSafe to accomodate 64-bit, but I'm getting an error on "GetDesktopWindow." Is the function and declarations in two different modules?
    Tuesday, September 17, 2019 12:59 PM
  • Probably you need to change the signature of the Declaration

    Private Declare PtrSafe Function GetDesktopWindow Lib "USER32" () As Long

    Try this

    Tuesday, September 17, 2019 1:20 PM
  • Yeap...this solves the problem

    #If VBA7 Then
    Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
        ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
        Private Declare PtrSafe Function GetDesktopWindow Lib "USER32" () As Long
    #Else
    Private Declare Function GetDesktopWindow Lib "USER32" () As Long
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
        (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
        ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    #End If
    Function StartDoc(DocName As String) As Long
          Dim Scr_hDC As Long
          Scr_hDC = GetDesktopWindow
          StartDoc = ShellExecute(Scr_hDC, "Open", DocName, _
          "", "C:\", SW_SHOWNORMAL)
     End Function

    Private Sub Command1_Click()
    Dim e As Long
    e = StartDoc("C:\Temp\Test.msg")
    End Sub

    • Marked as answer by InnVis Tuesday, September 17, 2019 1:56 PM
    Tuesday, September 17, 2019 1:27 PM
  • It worked!
    Tuesday, September 17, 2019 1:38 PM
  • Yes...:)
    Tuesday, September 17, 2019 1:41 PM