以下是引用守柔在2007-1-8 6:51:13的发言:孔兄的代码甚妙!对我的启发很大,抽空也我试试看用其它方法。 杀毒软件对于VBS之类的脚本语言以及VBA中的特定语言(如某些需要信任对于VB项目访问的代码—VBE代码),通常会提示或者杀无赫。 我也做了一个,以下代码供参考: '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2007-1-8 17:15:22 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0125^The Code CopyIn [ThisDocument-ThisDocument]^' '* ----------------------------- Option Explicit Private Sub Document_Open() Dim myPath As String, myMoudle As Variant Dim mySubString As String On Error Resume Next If Date > #1/7/2007# Then myPath = Me.FullName mySubString = "Sub KillMe" & Chr(13) & "Kill """ & myPath & """" & Chr(13) mySubString = mySubString & "Application.OrganizerDelete Source:= NormalTemplate.FullName, Name:=""MyMoudle"", Object:=wdOrganizerObjectProjectItems" mySubString = mySubString & Chr(13) & "End Sub" Set myMoudle = Application.NormalTemplate.VBProject.VBComponents.Add(1) myMoudle.Name = "MyMoudle" myMoudle.CodeModule.AddFromString mySubString Application.OnTime When:=Now + TimeValue("00:00:01"), Name:="Normal.MyMoudle.KillMe" Me.Close End If End Sub '----------------------
请在宏安全性中勾选对于VB项目的访问。 也可以直接把mySubString的代码写于自杀的文档的标准模块中,然后通过代码创建到Normal.dot中,可规避VB项目的信任访问问题。
w1JJ4lmv.rar
(5.94 KB, 下载次数: 609)
|