TSaveDialog Object

Applies to TestComplete 14.72, last modified on April 22, 2021

The TSaveDialog component is a file-selection modal dialog where a user can select a file or several files to save data. TSaveDialog contains a number of specific properties, methods and events that let you control various aspects of the dialog's appearance and behavior.

To display the dialog, call the Execute method. You can use the return value of this method to obtain the dialog result. To get the path to the selected file, use the FileName property.

The following example demonstrates the use of the TSaveDialog component in scripts. It requires a form named Form1 with the TcxMemo component named cxMemo1 and the TSaveDialog component named SaveDialog1. The code displays the dialog, and if the user chose the file and pressed the Save button, the text displayed in the memo is stored to the selected file.

JavaScript, JScript

var form = UserForms.Form1;
var oDialog = form.SaveDialog1;
if (oDialog.Execute())
  form.cxMemo1.Lines.SaveToFile(oDialog.FileName);

Python

form = UserForms.Form1
oDialog = form.SaveDialog1
if (oDialog.Execute()):
  form.cxMemo1.Lines.SaveToFile(oDialog.FileName)

VBScript

Set form = UserForms.Form1
Set oDialog = form.SaveDialog1
If oDialog.Execute Then
  form.cxMemo1.Lines.SaveToFile(oDialog.FileName)
End If

DelphiScript

var
  form, oDialog : OleVariant;
...
form := UserForms.Form1;
oDialog := form.SaveDialog1;
if oDialog.Execute then
  form.cxMemo1.Lines.SaveToFile(oDialog.FileName);

C++Script, C#Script

var form = UserForms["Form1"];
var oDialog = form.SaveDialog1;
if (oDialog["Execute"]())
  form["cxMemo1"]["Lines"]["SaveToFile"](oDialog["FileName"]);

The TSaveDialog component raises a number of events that you can process in your scripts. For example, you can create an event handler for the OnSelectionChange event to perform desired actions when the selected file is changed.

TSaveDialog Properties

TSaveDialog Methods

TSaveDialog Events

See Also

User Forms
TOpenDialog Object
TSelectDirectory Object

Highlight search results