Microsoft KB Archive/209186

= WD2000: How to Use Other Converters with the FileFormat Property =

Article ID: 209186

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q209186





SUMMARY
The SaveAs method of the Document object in Microsoft Visual Basic for Applications has an optional parameter called FileFormat that you can use to specify the save format for the document.

This article describes how to use the FileFormat property of the SaveAs method to specify a converter that is not supported with one of the supplied constants (values).



MORE INFORMATION
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.

For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:

212536 OFF2000: How to Run Sample Code from Knowledge Base Articles

The FileFormat optional variant (argument) specifies the format in which the document is to be saved and can be one of the following native (built-in) wdSaveFormat constants.

Other File Types
If you record a macro that saves a file as a type that is not supported by one of the constants described earlier, the FileFormat property will contain a number. The following sample macro was recorded by using RFT-DCA as the Save As Type:

Sub Macro1

ActiveDocument.SaveAs FileName:="Doc1.rft", FileFormat:=101

End Sub NOTE: The number 101 that was recorded for the RTF-DCA FileFormat argument is system specific. This number may not be the same on another computer.

To retrieve the correct FileFormat number for a conversion type for any computer, use the FileConverters collection. The following sample Visual Basic for Applications macro saves a document in RTF-DCA format on any computer.

NOTE: In the following sample, replace "RFTDCA" with the class name that you want to Save As. For a list of class names, see the "How to Obtain Class Names" section later in this article.

Sub SaveAsRFTDCA

Dim fcCnv As FileConverter Dim strClass As String Dim strFileName As String Dim x 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 = "RFTDCA"

' Set the FileName to use for saving. strFileName = "MyFile"

' 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 x = "Saved" End If

End With

Next fcCnv

If x = "Saved" Then

' If converter found, tell user document saved with converter. MsgBox "Your document has been saved in the " & Chr$(34) _ & strClass & Chr$(34) & " format." Else

' If converter not found, tell user to install converter. MsgBox "The " & Chr$(34) & strClass & Chr$(34) & _ " converter is not installed. Please install it!" End If

End Sub For more information about the SaveFormat property, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type SaveFormat in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

How to Obtain Class Names
The following list contains converters and class names that are installed by Word and that you can use for saving a document.

To retrieve other class names for an installed converter to Save As, you can loop through the FileConverters collection.

The following sample macro loops through all installed converters that you can use for saving, and then it 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 For more information about the ClassName property, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type ClassName in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

