Macro virus warning appears when no macros exist in the file in Word

Article translations Article translations
Article ID: 290960 - View products that this article applies to.
This article was previously published under Q290960
For a Microsoft Word 2000 version of this article, see 238851.

For a Microsoft Word 97 version of this article, see 161515.

Expand all | Collapse all

On This Page

SYMPTOMS

When you open a Microsoft Word 2002 document or template, you may receive the following macro virus warning, even though the document or template does not contain macros:
C:\<path>\<file name> contains macros.

Macros may contain viruses. It is always safe to disable macros, but if the macros are legitimate, you might lose some functionality.

CAUSE

When you delete macros from a document or template, some macro storage components are left behind. The macro virus protection feature finds this information, and the warning message may be displayed.

WORKAROUND

Microsoft Office Word 2007

To work around this problem, use one of the following methods, as appropriate for your situation.

Method 1: Delete the remaining macro storage component

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Macros that are contained in your Word document or in your template are saved in a module. After you delete macros from a document or from a template, the module that contained the macros remains. The module is not removed when the macros are deleted. When you remove a module, the macros that it contains are deleted.

To delete the module from a Word document or from a template and to prevent the macro virus warning from appearing, follow these steps:
  1. Open the document or the template that gives the macro virus warning.
  2. On the Developer tab, click Visual Basic in the Code group.
  3. In the Visual Basic window, expand Project (file name) in the Project pane. The document project or the template project should resemble the following example:
    Project (file name)
    Note If the Project window is not visible, click Project Explorer on the View menu. To expand the document project or the template project, click the plus sign to the left of the Project (file name).
  4. Expand the Modules folder.
  5. Click to select the module. For example, click to select NewMacros.

    Note The name of the module that is listed may be different in your document project or in your template project. For example, it may be named Module1 or a different name.
  6. On the File menu, click Remove Module Name. Click No on the following message:
    Do you want to export <Module Name> before removing it?
    Note If you are uncertain whether the module that you are removing contains macros, click Yes. Then, export the module as a Basics (*.bas) file.
  7. Repeat steps 5 and 6 for each module that is listed under the Project (file name) Modules folder.
  8. On the File menu, click Close and return to Microsoft Word.
  9. Save and close the Word document or the Word template.
The macro virus warning no longer appears when you open the document or the template.

Method 2: Copy the template to a new Word file

Note Use this procedure if the following conditions are true:
  • Your Word template contains no macros.
  • Your Word template displays the macro virus warning that is mentioned in the "Symptoms" section when you open the Word template or when you try to create a new document based on the template. For example, you click the Microsoft Office Button, and then you click New.
Note After the new template is created, you can copy all custom styles and AutoText entries to the new template. However, do not copy any macros to the new template.
  1. Click the Microsoft Office Button, and then click Close to close the file that displays the macro virus warning.
  2. Click the Microsoft Office Button, and then click New.
  3. In the Blank and recent pane, click to select Blank document, and then click Create.
  4. On the Insert tab, click Object in the Text group.
  5. In the Object dialog box, click Browse on the Create from File tab.
  6. Change the path of the Look in box to the folder that contains the problematic template. For example, change the path of the Look in box to the following folder:
    C:\Users\User_Name\AppData\Roaming\Microsoft\Templates
    Note Your template may be found in a different folder.
  7. Click to select the problematic template, and then click Insert.
  8. Click the Microsoft Office Button, and then click Save As.
  9. In the Save As dialog box, select Document Template (*.dot) in the Save as type box.
  10. In the File name box, type a name for your new template, and then click Save.
  11. Click the Microsoft Office Button, and then click Close to close your new template.
Note Macros or remaining macro storage components from your problematic template are not saved to the new template. The macro virus warning no longer appears when you open the template or when you use it to create a new document.

Method 3: Save the Word document as a Rich Text Format (.rtf) file

Note Use this procedure when your Word document contains no macros but displays the macro virus warning that is mentioned in the "Symptoms" section.
  1. Open the document that displays the macro virus warning.
  2. Click the Microsoft Office Button, and then click Save As.
  3. In the Save As dialog box, click Rich Text Format (*.rtf) under Save as type, and then click Save. Click Yes in the following message:
    All macros in this document will be lost if the document is saved in Rich Text Format. Do you want to save in this format anyway?
  4. On the File menu, click Close to close the .rtf file that you saved in step 3.
  5. On the File menu, click Open, and then open the .rtf file that you saved in step 3.
  6. On the File menu, click Save As.
  7. In the Save As dialog box, select Word Document (*.doc) under Save as type, and then click Save.

    Note If you are saving the file back to its original file name, click Continue on the following Microsoft Office Word Compatibility Checker message:
    The following features in this document are not supported by earlier versions of Word. These features may be lost or degraded when you save this document in an earlier file format. Click Continue to save the document. To keep all of your features, click Cancel, and then save the file in one of the new file formats.

    Summary

    Macros will be lost.
  8. Close and then reopen the file.
Note Macros or remaining macro storage components are not saved to the new file. The macro virus warning no longer appears when you open the file.

Alternatively, run the following macro:
Option Explicit

Const stFindFolder = "C:\test"
Sub roundtrip_wordfile_rtf()
    'Dim objDoc 'As Document
    Application.ScreenUpdating = False
    Dim objDocName  As String
    Dim i
    Dim FoundCnt
    Dim SrcFileFullName
    Dim objDocRtfName As String
    Dim objDocDocName As String
    Dim objDocShortName As String
    
    Dim wdApp As Object 'As Word.Application 'Object
    Set wdApp = CreateObject("Word.Application")
    wdApp.Visible = False 'Hides the application.
    wdApp.DisplayAlerts = wdAlertsNone 'Turns off any Dialog Boxes.
    
    With Application.FileSearch
        .NewSearch
        .Filename = "*.doc"
        .LookIn = stFindFolder
        .SearchSubFolders = False 'True  'Set this to True if you want to search Sub Folders.
        .TextOrProperty = ""
        .Execute 'The .Execute command may take a while.


        FoundCnt = .FoundFiles.Count
        For i = 1 To FoundCnt
            SrcFileFullName = .FoundFiles(i)
            If Len(Dir(SrcFileFullName)) > 0 Then
            
            Debug.Print SrcFileFullName 'This prints out the name fo the file that was worked on in the Immediate Window.
    wdApp.Documents.Open (SrcFileFullName)
    objDocRtfName = Replace(SrcFileFullName, ".doc", ".rtf", 1, , vbTextCompare) 'Changes the file name to *.rtf.
    'objDocShortName = Replace(objDocRtfName, stFindFolder & "\", "", 1, , vbTextCompare)'In case yoiu need the short file name.
    
     wdApp.Documents(SrcFileFullName).SaveAs Filename:=objDocRtfName, FileFormat:=wdFormatRTF, _
        LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
        :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
        False
wdApp.Documents.Close 
    wdApp.Visible = False
    'objDoc.Close
    wdApp.Documents.Open objDocRtfName
    objDocDocName = Replace(objDocRtfName, ".rtf", ".doc", 1, , vbTextCompare) 'Changes the file name to *.doc.
    wdApp.Documents(objDocRtfName).SaveAs Filename:=objDocDocName, FileFormat:=wdFormatRTF, _
        LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
        :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
        False
    
    wdApp.Documents.Close 
    wdApp.Visible = False
    Kill objDocRtfName 'This deletes the *.rtf file used to remove the macros.
            End If
        Next i
    End With
    
    wdApp.Quit
    Set wdApp = Nothing
    
End Sub

Microsoft Word 2002

To work around this problem, use one of the following methods appropriate for your situation.

Method 1: Delete the Remaining Macro Storage Component

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Macros that are contained in your Word document or template are saved in a module. After you delete macros from a document or template, the module that contained the macros remains and is not removed when the macros are deleted.

To delete the module from your Word document or template and prevent the macro virus warning from appearing, follow these steps.

Note Removing a module deletes the macros that it contains.
  1. Open the document or template that gives the macro virus warning.
  2. On the Tools menu, point to Macro, and then click Visual Basic Editor.
  3. In the Project window, expand the document (template) project. The document (template) project should look similar to the following example:
    Project (file name)
    NOTE: If the Project window is not visible, click Project Explorer on the View menu.
  4. Expand the Modules folder.
  5. Click to select the module. For example, click to select NewMacros.

    Note The name of the module that is listed may be different in your document (template) project. For example, it may be named Module1 or some different name.
  6. On the File menu, click Remove Module Name. Click No to the following message:
    Do you want to export <Module Name> before removing it?
    NOTE: If you are uncertain whether the module you are removing contains macros, click Yes and then export the module as a Basics Files (*.bas).
  7. Repeat steps 5 and 6 for each module that is listed under the Project (file name) Modules folder.
  8. On the File menu, click Close and return to Microsoft Word.
  9. Save and close the Word document (template).
The macro virus warning no longer appears when you open the document (template).

Method 2: Copy the Template to a New Word File

Note Use this procedure when your Word template contains no macros but displays the macro virus warning as described in the "Symptoms" section of this article when you open it or try to create a new document based on it (on the File menu, click New). Create a new template by following these steps.

Note After the new template is created, you can copy all custom styles, AutoText entries, and so on to the new template, but do not copy any macros to the new template.
  1. On the File menu, click Close to close the file that displays the macro virus warning.
  2. On the File menu, click New.
  3. On the General tab, click to select Blank Document, and then click OK.
  4. On the Insert menu, click File.
  5. In the Insert File dialog box, change the Files of type box to Document Templates (*.dot).
  6. Change the Look in box to the folder that contains the problem template. For example, change the Look in box to the following folder:
    C:\WINDOWS\Application Data\Microsoft\Templates
    NOTE: Your template may be found in a different folder.
  7. Click to select the problem template, and then click Insert.
  8. On the File menu, click Save As.
  9. In the Save As dialog box, change the Save as type box to Document Template (*.dot).
  10. In the File name box, type a file name for your new template, and then click Save.
  11. On the File menu, click Close to close your new template.
Any macros or remaining macro storage components from your problem template are not saved to the new template. The macro virus warning no longer appears when you open the template or use it to create a new document.

Method 3: Save the Word Document as Rich Text Format (RTF)

Note Use this procedure when your Word document contains no macros but displays the macro virus warning as described in the "Symptoms" section.
  1. Open the document that gives the macro virus warning.
  2. On the File menu, click Save As.
  3. In the Save As dialog box, under Save as type, click Rich Text Format (*.rtf), and then click Save. Click Yes to the following message:
    All macros in this document will be lost if the document is saved in Rich Text Format. Do you want to save in this format anyway?
  4. On the File menu, click Close to close the Rich Text Format document that you just saved.
  5. On the File menu, click Open and open the Rich Text Format document that you saved in step 3.
  6. On the File menu, click Save As.
  7. In the Save As dialog box, under Save as type, click Word Document (*.doc), and then click Save. If you are saving the file back to its original file name, click Yes to the following message:
    The file <file name> already exists. Do you want to replace the existing file?
  8. Close and reopen the document.
Any macros or remaining macro storage components are not saved to the new document. The macro virus warning no longer appears when you open the document.

Alternatively, run the following macro:
Option Explicit

Const stFindFolder = "C:\test"
Sub roundtrip_wordfile_rtf()
    'Dim objDoc 'As Document
    Application.ScreenUpdating = False
    Dim objDocName  As String
    Dim i
    Dim FoundCnt
    Dim SrcFileFullName
    Dim objDocRtfName As String
    Dim objDocDocName As String
    Dim objDocShortName As String
    
    Dim wdApp As Object 'As Word.Application 'Object
    Set wdApp = CreateObject("Word.Application")
    wdApp.Visible = False 'Hides the application.
    wdApp.DisplayAlerts = wdAlertsNone 'Turns off any Dialog Boxes.
    
    With Application.FileSearch
        .NewSearch
        .Filename = "*.doc"
        .LookIn = stFindFolder
        .SearchSubFolders = False 'True  'Set this to True if you want to search Sub Folders.
        .TextOrProperty = ""
        .Execute 'The .Execute command may take a while.


        FoundCnt = .FoundFiles.Count
        For i = 1 To FoundCnt
            SrcFileFullName = .FoundFiles(i)
            If Len(Dir(SrcFileFullName)) > 0 Then
            
            Debug.Print SrcFileFullName 'This prints out the name fo the file that was worked on in the Immediate Window.
    wdApp.Documents.Open (SrcFileFullName)
    objDocRtfName = Replace(SrcFileFullName, ".doc", ".rtf", 1, , vbTextCompare) 'Changes the file name to *.rtf.
    'objDocShortName = Replace(objDocRtfName, stFindFolder & "\", "", 1, , vbTextCompare)'In case yoiu need the short file name.
    
     wdApp.Documents(SrcFileFullName).SaveAs Filename:=objDocRtfName, FileFormat:=wdFormatRTF, _
        LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
        :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
        False
wdApp.Documents.Close 
    wdApp.Visible = False
    'objDoc.Close
    wdApp.Documents.Open objDocRtfName
    objDocDocName = Replace(objDocRtfName, ".rtf", ".doc", 1, , vbTextCompare) 'Changes the file name to *.doc.
    wdApp.Documents(objDocRtfName).SaveAs Filename:=objDocDocName, FileFormat:=wdFormatRTF, _
        LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
        :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
        False
    
    wdApp.Documents.Close 
    wdApp.Visible = False
    Kill objDocRtfName 'This deletes the *.rtf file used to remove the macros.
            End If
        Next i
    End With
    
    wdApp.Quit
    Set wdApp = Nothing
    
End Sub

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

Macro storage components are not present in a Word document or template until you store a macro in the file. These components exist as supporting structures for the existence and storage of macros in a file. When you delete all of the macros in a file, the macro storage components are not removed. The macro virus warning feature of Microsoft Word detects the macro storage components in the file and presents the macro virus warning when you open the file.

To remove macros from a Word document, follow these steps:

Microsoft Word 2002

  1. Open the file in Word.
  2. On the Tools menu, point to Macro, and then click Macros.
  3. In the Macros dialog box, select a macro name, and then click Delete. This removes the macro from the file.
  4. Repeat step 3 for each macro that you want to remove.

Microsoft Office Word 2007

  1. Open the file in Word 2007.
  2. On the Developer tab, click Macros in the Code group.
  3. In the Macros dialog box, select a macro name, and then click Delete. This removes the macro from the file.
  4. Repeat step 3 for each macro that you want to remove.
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
233396 How to reduce the chances of macro virus infection

Properties

Article ID: 290960 - Last Review: March 28, 2007 - Revision: 3.0
APPLIES TO
  • Microsoft Office Word 2003
  • Microsoft Word 2002 Standard Edition
  • Microsoft Office Word 2007
Keywords: 
kbbug kbpending KB290960

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com