以下是引用守柔在2007-1-8 17:19:15的发言:我也做了一个,以下代码供参考: '* +++++++++++++++++++++++++++++ '* 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项目的信任访问问题。 |