locked
Adding Trusted Locations for Microsoft Office via VBS RRS feed

  • Question

  • Does anyone know of a reliable script to add trusted locations for Microsoft Office (Word and Excel Specifically)?

    I know it's a registry edit, but I was wondering if there was a VBS already made that someone can refer me to.

    Thursday, November 8, 2012 7:57 PM

Answers

  • Here it is: 

    Customize the value of the strFolder variable on line 2 with the location of the new Trusted Location.
    Customize the value of the strDescription on line 3 with the description to display.
    Customize the value of the blnAllowSubFolders variable on line 4 with True or False. 

    Const HKEY_CURRENT_USER = &H80000001
    strFolder = "D:\databases"
    strDescription = "The new trusted location"
    blnAllowSubFolders = True
     
    strParentKey = "Software\Microsoft\Office\14.0\Word\Security\Trusted Locations"
    'strParentKey = "Software\Microsoft\Office\14.0\Excel\Security\Trusted Locations"
    intLocCounter = 0
     
    Set objRegistry = GetObject("winmgmts:\\.\root\default:StdRegProv")
     
    objRegistry.EnumKey HKEY_CURRENT_USER, strParentKey, arrChildKeys
     
    For Each strChildKey in arrChildKeys
        If CInt(Mid(strChildKey, 9)) > intLocCounter Then
            intLocCounter = CInt(Mid(strChildKey, 9))
        End If
    Next
    strNewKey = strParentKey & "\Location" & CStr(intLocCounter + 1)
     
    objRegistry.CreateKey HKEY_CURRENT_USER, strNewKey
    objRegistry.SetStringValue HKEY_CURRENT_USER, strNewKey, "Path", strFolder
    objRegistry.SetStringValue HKEY_CURRENT_USER, strNewKey, "Description", strDescription
     
    If blnAllowSubFolders Then
        objRegistry.SetDWORDValue HKEY_CURRENT_USER, strNewKey, "AllowSubFolders", 1
    End If

    Max Meng
    TechNet Community Support
    A new Office has arrived, try it now.
    A beautiful Start. It begins here. Windows 8 and Windows RT.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Max Meng Monday, November 19, 2012 8:39 AM
    Sunday, November 11, 2012 9:40 AM