Macro virus warning appears when no macros exist in the file in Word (290960)
The information in this article applies to:
- Microsoft Office Word 2003
- Microsoft Word 2002
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.
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
To work around this problem, use one of the following methods appropriate for your situation.
Method 1: Delete the Remaining Macro Storage ComponentMicrosoft 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.
- Open the document or template that gives the macro virus warning.
- On the Tools menu, point to Macro, and then click Visual Basic Editor.
- In the Project window, expand the document (template) project. The document (template) project should look similar to the following example:
NOTE: If the Project window is not visible, click Project Explorer on the View menu. To expand the document (template) project, click the plus sign to the left of the Project (file name).
- Expand the Modules folder.
- 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. - 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). - Repeat steps 5 and 6 for each module that is listed under the Project (file name) Modules folder.
- On the File menu, click Close and return to Microsoft Word.
- 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 FileNote 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.
- On the File menu, click Close to close the file that displays the macro virus warning.
- On the File menu, click New.
- On the General tab, click to select Blank Document, and then click OK.
- On the Insert menu, click File.
- In the Insert File dialog box, change the Files of type box to Document Templates (*.dot).
- 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. - Click to select the problem template, and then click Insert.
- On the File menu, click Save As.
- In the Save As dialog box, change the Save as type box to Document Template (*.dot).
- In the File name box, type a file name for your new template, and then click Save.
- 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.
- Open the document that gives the macro virus warning.
- On the File menu, click Save As.
- 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? - On the File menu, click Close to close the Rich Text Format document that you just saved.
- On the File menu, click Open and open the Rich Text Format document that you saved in step 3.
- On the File menu, click Save As.
- 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? - 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
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Modification Type: | Major | Last Reviewed: | 6/17/2005 |
---|
Keywords: | kbbug kbpending KB290960 |
---|
|