Article ID: 224066
Article Last Modified on 12/2/2005
APPLIES TO
- Microsoft Word 2000 Standard Edition
This article was previously published under Q224066
THINGS TO TRY
If you record a macro that changes the file type, the FileFormat property will contain a number. The following sample macro was recorded using HTML as the "Save as type":
Sub Macro1() ActiveDocument.SaveAs FileName:="myHTMLdoc", FileFormat:=103 End Sub
NOTE: The number 103 was recorded for the HTML FileFormat argument. This number may not be the same on another computer.
Use any of the following methods to resolve this problem.
Method 1: Use the FileFormat Built-in Conversion Constant
FileFormat accepts the following built-in conversion constants:
wdFormatDocument
wdFormatDOSText
wdFormatDOSTextLineBreaks
wdFormatEncodedText
wdFormatHTML
wdFormatRTF
wdFormatTemplate
wdFormatText
wdFormatTextLineBreaks
wdFormatUnicodeText
For example, to use a constant for the HTML save example earlier in this article, use the following:
ActiveDocument.SaveAs FileName:= "myHTMLdoc", FileFormat:= WdFormatHTML
Method 2: Use the FileConverters Collection to Retrieve the Correct FileFormat Number for a Conversion Type for Any Computer
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. The following sample Visual Basic for Applications macro saves a document in HTML format on any computer:
NOTE: In the following example, replace "HTML" with the class name you want to use for Save As. For a list of class names, see the "Use the Class Name of the Converter" section later in this article.
Sub SaveAsHTML() Dim fcCnv As FileConverter Dim strClass As String Dim strFileName As String ' If there are no documents open to ' save, exit this routine. If Documents.Count = 0 Then Exit Sub ' Set the ClassName to use for saving. strClass = "HTML" ' Set the FileName to use for saving. strFileName = "MyHTMLdoc" ' Loop through all installed converters. For Each fcCnv In FileConverters With fcCnv ' Test for conversion ClassName. If .ClassName = strClass Then ' Save using the FileConverters.ClassName. ActiveDocument.SaveAs FileName:=strFileName, _ FileFormat:=.SaveFormat End If End With Next fcCnv End Sub
Method 3: Use the Class Name of the Converter
The following list contains converters and class names that are installed by Word and that you can use for saving a document.
Converter | ClassName |
---|---|
HTML Document | HTML |
MS-DOS Text with Layout | MS-DOS Text with Layout |
Text with Layout | Text with Layout |
Word 2.x for Windows | MSWordWin2 |
Word 4.0 for Macintosh | MSWordMac4 |
Word 5.0 for Macintosh | MSWordMac5 |
Word 5.1 for Macintosh | MSWordMac51 |
WordPerfect 5.0 | WrdPrfctDOS50 |
WordPerfect 5.1 for DOS | WrdPrfctDOS51 |
WordPerfect 5.x for Windows | WrdPrfctWin |
WordPerfect 5.1 or 5.2 Secondary File | WrdPrfctDat |
WordPerfect 5.0 Secondary File | WrdPrfctDat50 |
Works 3.0 for Windows | MSWorksWin3 |
Works 4.0 for Windows | MSWorksWin4 |
Word 6.0/95 | MSWord6Exp |
Word 97 & 6.0/95 - RTF | MSWord6RTFExp |
To retrieve other class names for an installed converter to use for a Save As operation, you can loop through the FileConverters collection.
The following sample macro loops through all installed converters that you can use for saving and then inserts the converter name and associated class name into a blank document:
Sub GetConvClassName() Dim fcCnv As FileConverter ' Create blank document. Documents.Add ' Loop through all installed converters. For Each fcCnv In FileConverters With fcCnv ' If the converter can be used to save... If .CanSave = True Then ' Insert the converter name and class name in the document. Selection.TypeText "Converter: " & .FormatName & vbTab _ & "ClassName: " & .ClassName & vbCr End If End With Next fcCnv End Sub
MORE INFORMATION
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
209186 WD2000: How to Use Other Converters with the FileFormat Property
Additional query words: OFF2000
Keywords: wd2000 kbdta kbprb KB224066