操作注册表,VBA代码: Sub macro1()'全选 Dim wsh As Object, v As String v = "HKEY_CURRENT_USER\Software\Microsoft\Office\" & Application.Version & "\Excel\Security\" Set wsh = WScript.CreateObject("Wscript.Shell") wsh.RegWrite v & "Level", 2, "REG_DWORD" wsh.RegWrite v & "DontTrustInstalledFiles", 0, "REG_DWORD" wsh.RegWrite v & "AccessVBOM", 1, "REG_DWORD" Set wsh = Nothing End Sub Sub macro2()'不选 Dim wsh As Object, v As String v = "HKEY_CURRENT_USER\Software\Microsoft\Office\" & Application.Version & "\Excel\Security\" Set wsh = WScript.CreateObject("Wscript.Shell") wsh.RegWrite v & "Level", 2, "REG_DWORD" wsh.RegWrite v & "DontTrustInstalledFiles", 1, "REG_DWORD" wsh.RegWrite v & "AccessVBOM", 0, "REG_DWORD" Set wsh = Nothing End Sub |