ShowOpenFileDialog method (WinStudio scripts)
Applies To
IWSApplication interface
Definition
Opens a standard Windows Open File dialog box, optionally passing the path and name of a file to open; and returns the path and file name the user selects.
Syntax
Application.ShowOpenFileDialog( string1, string2, string3, [ string4, string5, string6 ] )
Part | Description |
string1 | Required. By reference, the path and name of the file to be opened. |
string2 | Required. The text that appears in the title bar of the Open File dialog box. |
string3 | Required. A
string containing a pipe-delimited list of file extension filters. These
filters control what is displayed in the file selection field.
These filters must each use the format: fileType|*.ext where:
Example: The following example causes the Files of type drop-down list in the Open File dialog box to include options for JPG, PNG, and All files. "JPG files (*.jpg)|*.jpg|PNG files (*.png)|*.png|All files (*.*)|*.*" To specify no filters, use an empty string (""). |
string4 | Optional. The
extension that the system should add as the default extension to a file name if
no other extension is specified.
For example, suppose you specify "txt" for this string. If a user then specifies MyFile as the file name (with no extension) then the system automatically appends a dot ( . ) and this default extension. In this case, the system returns the file name as MyFile.txt. If the user does specify an extension, (for example, MyFile.doc or MyFile.txt), then the system appends nothing to the file name. To specify no default extension, use an empty string ("") for this. In this case, the system adds no extension if the user does not specify one. If you use this parameter, you must also use string5, and vice versa. |
string5 | Optional. The
full path to the default folder to open when the
Open File dialog box opens.
Example: C:\Temp\Graphics If the specified folder does not exist, the system defaults to whatever the "current" folder is. To specify no default path, use an empty string ("") for this. If you use this parameter, you must also use string4, and vice versa. |
string6 | Optional. This Boolean parameter defaults to False. If set to true, the Open File dialog box prompts a user to upload a new or existing photo from a device. There is a preview image shown on the dialog on web. This has no filtering effect on a standard browser. |
Remarks
The return is a string containing the path and file name that the user selected.
Example
Public Sub OpenFileDialog() Dim FileName As String FileName = String.Empty Application.ShowOpenFileDialog(FileName, "Open File", _ "JPG files (*.jpg)|*.jpg|PNG files (*.png)|*.png|All files (*.*)|*.*", _ "", "C:\WINDOWS\Web\Wallpaper") Application.ShowMessage("Test value = " & FileName) End Sub
This example, only new or existing pictures can be opened in the Open File dialog box on a mobile device.
Public Sub OpenFileDialog() Dim FileName As String FileName = String.Empty Application.ShowOpenFileDialog(FileName, "Open File", _ "JPG files (*.jpg)|*.jpg|PNG files (*.png)|*.png|All files (*.*)|*.*", _ "", "", true) Application.ShowMessage("Test value = " & FileName) End Sub