- Private Sub 启用宏()
- Dim RK As RegistryKey = Registry.CurrentUser
- Dim arr As String() = {"16.0", "15.0", "14.0", "12.0", "8.0"}
- Try
- For Each v In arr
- Dim RK1 As RegistryKey = RK.OpenSubKey("Software\Microsoft\Office" + v + "\Excel\Security", True)
- If Not RK1 Is Nothing Then
- RK1.SetValue("AccessVBOM", 1)
- RK1.SetValue("VBAWarnings", 1)
- End If
- Dim RK2 As RegistryKey = RK.OpenSubKey("Software\Microsoft\Office" + v + "\Word\Security", True)
- If Not RK2 Is Nothing Then
-
- RK2.SetValue("AccessVBOM", 1)
- RK2.SetValue("VBAWarnings", 1)
- End If
-
- Dim RK3 As RegistryKey = RK.OpenSubKey("Software\Microsoft\Office" + v + "\PowerPoint\Security", True)
-
- If Not RK3 Is Nothing Then
- RK3.SetValue("AccessVBOM", 1)
- RK3.SetValue("VBAWarnings", 1)
- End If
-
- Dim RK4 As RegistryKey = RK.OpenSubKey("Software\Microsoft\Office" + v + "\Outlook\Security", True)
-
- If Not RK4 Is Nothing Then
- RK4.SetValue("Level", 1)
- End If
-
-
-
- Dim RK5 As RegistryKey = RK.OpenSubKey("Software\Microsoft\Office" + v + "\Access\Security", True)
-
- If Not RK5 Is Nothing Then
- RK5.SetValue("VBAWarnings", 1)
- End If
- Next
-
- ' //WPS宏设置
-
- Dim RKWPS As RegistryKey = RK.OpenSubKey("Software\Kingsoft\Office\6.0\wps\Application Settings", True)
-
- If Not RKWPS Is Nothing Then
- RKWPS.SetValue("VbaSecurityLevel", 1)
- RKWPS.SetValue("VbaVBProjectTrustCheck", 1)
- End If
- Dim RK0 As RegistryKey = RK.OpenSubKey("Software\Microsoft\Office\Common\Security", True)
- If Not RK0 Is Nothing Then
- RK0.SetValue("DisableAllActiveX", 0)
- End If
- Me.宏启用.Text = "宏已经启用,请关闭此软件并重新打开表格文件"
- Catch ex As Exception
- Me.宏启用.Text = "启用宏失败!"
- End Try
-
-
-
- End Sub
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复有时候你的的宏程序给别人用,使用者不知道如何去启用宏而导致无法使用,那么你将此程序发给他们,宏会自动启用,再打开你的表格就可以正常运行了
|