|
- Sub TrustVBA()
- Dim strKey1 As String, strKey2 As String, strKey3 As String, strKey4 As String
- Dim KeyValue1 As String, KeyValue2 As String
- Dim KeyValue As Long
- Dim strVersion As String
- On Error Resume Next
- strVersion = Application.Version
- strKey1 = "HKEY_CURRENT_USER\Software\Microsoft\Office" & strVersion & "\Excel\Security\AccessVBOM"
- strKey2 = "HKEY_CURRENT_USER\Software\Microsoft\Office" & strVersion & "\Excel\Security\Level"
- strKey3 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Office" & strVersion & "\Excel\Security\AccessVBOM"
- strKey4 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Office" & strVersion & "\Excel\Security\Level"
- 'AccessVBOM 允许访问VBA对象
- Call WriteReg(strKey1, 1, "REG_DWORD")
- Call WriteReg(strKey2, 1, "REG_DWORD")
- Call WriteReg(strKey3, 1, "REG_DWORD")
- Call WriteReg(strKey4, 1, "REG_DWORD")
- End Sub
- Sub WriteReg(strkey As String, Value As Variant, ValueType As String)
- Dim objWshell As Object
- Set objWshell = CreateObject("WScript.Shell")
- On Error Resume Next
- If ValueType = "" Then
- objWshell.REGWRITE strkey, Value
- Else
- objWshell.REGWRITE strkey, Value, ValueType
- End If
- Set objWshell = Nothing
- End Sub
复制代码 |
|