Dialog Box Scripting Techniques
Locate a File Using a File Open Dialog BoxSave a File Using a File Save Dialog Box
You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.
Locate a File Using a File Open Dialog Box
Demonstration script that displays a File Open dialog box (open to the folder C:\Scripts), and then echoes back the name of the selected file.
Set objDialog = CreateObject("UserAccounts.CommonDialog") objDialog.Filter = "VBScript Scripts|*.vbs|All Files|GetAdsiDatabase" objDialog.FilterIndex = 1 objDialog.InitialDir = "C:\Scripts" intResult = objDialog.ShowOpen If intResult = 0 Then Wscript.Quit Else Wscript.Echo objDialog.FileName End If
Save a File Using a File Save Dialog Box
Demonstration script that allows you to enter a file name in a File Save dialog box, and then saves a sample text file (consisting entirely of the current date) under that file name.
Set objDialog = CreateObject("SAFRCFileDlg.FileSave") objDialog.FileName = "C:\Scripts\Script1.vbs" objDialog.FileType = "VBScript Script" intReturn = objDialog.OpenFileSaveDlg If intReturn Then Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.CreateTextFile(objDialog.FileName) objFile.WriteLine Date objFile.Close Else Wscript.Quit End If