How to Use WinWord to Convert RTF Files to Windows DOC Files

ID: Q242875


The information in this article applies to:
  • Microsoft Index Server version 2.0
  • Microsoft Site Server version 3.0


SYMPTOMS

Microsoft Office documents are not indexed.


CAUSE

The Microsoft Office filter used by Microsoft Site Server Search and Microsoft Index Server only supports indexing HTML, plain text, and Microsoft Office documents (.doc, .dot, .ppt, .pot, .xlb, .xls, .xlc, .obd, .opt). Rich Text Format (RTF) files are not supported by the Microsoft Office filter because there are too many different RTF formats.


RESOLUTION

A Microsoft Word macro can be written to automatically convert the files to the Word for Windows DOC format. A sample is provided below. Modify as needed.


Sub convert()

 Dim strFile As String
 Dim X As String
 Dim Y As String
 Dim Z As Object
'Collect Drive and directory to convert Word Docs in.
 X = InputBox("Please enter the drive the documents are on.", "Drive Letter", "C")
 Y = InputBox("Please enter the path to the directory the files are in.", "Path to files", "My Documents")
'seed the string to the first file in the directory
 strFile = Dir(X & ":\" & (Y) & "\" & "*.rtf")
' Start looping through files opening and saving as current version of Word.
 On Error Resume Next
 Do While strFile <> ""
    Documents.Open X & ":\" & (Y) & "\" & strFile, Format:=wdOpenFormatRTF
    ActiveDocument.SaveAs (X & ":\" & Y & "\" & strFile), FileFormat = wdFormatDocument
    ActiveDocument.Close
    strFile = Dir
    
 Loop
'Alert user operation is complete
 MsgBox "done"

End Sub 


MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp

Additional query words:


Keywords          : 
Version           : winnt:2.0,3.0
Platform          : winnt 
Issue type        : kbprb 


Last Reviewed: October 28, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.