4

I have a VBA script that cycles through a list of ppt links to sharepoint, opens them, saves them in a temp location, extracts information from specific text boxes and closes them. However when I try to open the links, I get the security warning-

"Opening http://.....pptm

Some files can contain viruses or otherwise be harmful to your computer. It is imporant to be certain that this file is from a trustworthy source.

Would you like to open this file?"

I know I can disable this by going into the registries; however my company does not allow me to do so. Can anyone recommend a way to either

  1. Automatically close these warnings/disable them entirely
  2. Extract the information from the .ppts in another way.
Community
  • 1
  • 1
ChristinaM92
  • 41
  • 1
  • 2
  • have you tried Application.DisplayAlerts = false – Sorceri Aug 10 '15 at 19:09
  • 1
    I have- since the warning isn't originating from Excel, this doesn't seem to help. – ChristinaM92 Aug 10 '15 at 19:54
  • You can use the windows API to locate the handle of the popup warning and close it. Sid wrote up an excellent tutorial [here](http://stackoverflow.com/questions/16174469/unprotect-vbproject-from-vb-code/16176557#16176557) – findwindow Aug 10 '15 at 21:10

2 Answers2

2

Taking a look at the MS support page for that issue it seems that all the solutions for it are inevitably registry based.

Tested and working for all versions of Office (making use of the registry):

Disable the hyperlink warning:

CreateObject("Wscript.Shell").RegWrite _ 
             "HKCU\Software\Microsoft\Office\" & Application.Version &  _
             "\Common\Security\DisableHyperlinkWarning", 1, "REG_DWORD"

(Re-)Enable the hyperlink warning:

CreateObject("Wscript.Shell").RegWrite _ 
             "HKCU\Software\Microsoft\Office\" & Application.Version &  _
             "\Common\Security\DisableHyperlinkWarning", 0, "REG_DWORD"
TCN
  • 1,571
  • 1
  • 26
  • 46
1

I haven't tried them, but here are a few options:

.

  1. ShellExecute (API):

.

Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
                   (ByVal hwnd As Long, ByVal lpszOp As String, _
                    ByVal lpszFile As String, ByVal lpszParams As String, _
                    ByVal LpszDir As String, ByVal FsShowCmd As Long) _
                    As Long

More details from Microsoft

.

  1. Registry edit:

    1. Click Start, and then click Run.
    2. In the Open dialog box, type regedit, and then click OK.
    3. In Registry Editor, locate and then click one of the following registry subkeys: HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\11.0\Common

Notes:

  • You only have to modify one of these registry subkeys, not both of them.
  • If the HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\11.0\Common registry subkey does not exist, you may have to manually create it.

    1. After you click the registry subkey, point to New on the Edit menu, and then click Key.
    2. Type Security, and then press ENTER to name the key.
    3. On the Edit menu, point to New, and then click DWORD Value.
    4. Type DisableHyperlinkWarning, and then press ENTER to name the entry.
    5. In the right pane, right-click DisableHyperlinkWarning, and then click Modify.
    6. In the Edit DWORD Value dialog box, click Decimal, and then type 1 under Value data.

Note

  • A value of 0 enables the hyperlink warning message, and a value of 1 disables the warning message.

    1. Click OK.
    2. Quit Registry Editor.

More details from Microsoft1 and Microsoft2

.

  1. VBA code to modify the registry:

Option Explicit

Function killHyperlinkWarning()
    Dim oShell As Object
    Dim strReg As String

    strReg = "Software\Microsoft\Office\11.0\Common\Security\Dis ableHyperlinkWarning"

    Set oShell = CreateObject("Wscript.Shell")
    oShell.RegWrite "HKCU\" & strReg, 1, "REG_DWORD"
End Function

found here

paul bica
  • 10,557
  • 4
  • 23
  • 42