SaveFile Method

Applies to TestComplete 15.64, last modified on May 16, 2024


The method is applied to window objects that correspond to standard Save File dialogs. It simulates the selection of the specified file in the dialog and then closes the dialog.


TestObj.SaveFile(FileName, FileType)

TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
FileName [in]    Required    String    
FileType [in]    Optional    Variant Default value: -1   
Result None

Applies To

A window object that corresponds to a standard Save File dialog box:

View Mode

This method is available in the Object Browser panel and in other panels and dialogs in both Basic and Advanced view modes.


The method has the following parameters:


The fully-qualified name of the file to be selected.


A string or an integer value that specifies the type of the file to be selected. This parameter corresponds to the value that is shown in the Files of type box of the standard Save File dialog.

If FileType is specified, the method sets the appropriate value in this box before selecting the file. If FileType is omitted or is equal to -1, the method does not change the value of this box.

If FileType is a string, the method treats it as an item’s text that is shown in the drop-down list of the “Files of type” box. If FileType is an integer, the method treats it as the index of the desired item (indexes are zero-based). If the specified item was not found, the method posts an error message to the test log and does not save a file.

Result Value



TestComplete may fail to record the SaveFile method on Windows 7 and later; TestComplete will record interactions with the Save File dialog elements instead. However, you can modify the recorded test and manually replace them with the SaveFile method call.


For sample code that demonstrates how to use the method, see Working With Open File and Save File Dialogs.

See Also

OpenFile Method
Working With Open File and Save File Dialogs

Highlight search results