1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Sub SQLSecurity_Toggle()
'Pour changer la sécurité SQL / passer de "ON" à "OFF"
Dim WshShell, RegKey, rKeyWord, wVer
Set WshShell = CreateObject("WScript.Shell")
wVer = Application.Version
If wVer < 10 Then 'The security issue relates to
'Word versions greater than 10.0 (Word 2002)
MsgBox "This macro is for Word 2002 and later!", vbOKOnly, "Wrong Word Version"
Exit Sub
End If
Start:
RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\" & wVer & "\Word\Options\"
On Error Resume Next 'The registry key does not exist
rKeyWord = WshShell.RegRead(RegKey & "SQLSecurityCheck")
If rKeyWord = "" Then
WshShell.RegWrite RegKey & "SQLSecurityCheck", 1, "REG_DWORD" 'set it at zero
GoTo Start: 'and read it again
End If
If rKeyWord = 1 Then
WshShell.RegWrite RegKey & "SQLSecurityCheck", 0, "REG_DWORD"
MsgBox "SQL Security checking is switched off", vbInformation, "SQL Check"
Else
WshShell.RegWrite RegKey & "SQLSecurityCheck", 1, "REG_DWORD"
MsgBox "SQL Security checking is switched on", vbInformation, "SQL Check"
End If
End Sub |
Partager