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.