(view source code of comdlgfs.vbs as plain text)
' A script to demonstrate the File Save dialog available in COMDLG32.OCX
' Written by Rob van der Woude
' http://www.robvanderwoude.com
Option Explicit
Dim strFile
strFile = FileSaveDialog( )
If strFile = "" Then
If Err Then
WScript.Echo "File Save failed: " & Err.Description
Else
WScript.Echo "File Save was cancelled"
End If
Else
WScript.Echo "File saved as: """ & strFile & """"
End If
Function FileSaveDialog( )
' This function displays a "Save File" dialog and returns the
' fully qualified path of the entered file name or selected file
Dim objDialog, wshShell
Const OFN_HIDEREADONLY = &H4
Const OFN_CREATEPROMPT = &H2000
Const OFN_EXPLORER = &H80000
Const OFN_LONGNAMES = &H200000
FileSaveDialog = ""
Set wshShell = WScript.CreateObject( "Wscript.Shell" )
On Error Resume Next
Set objDialog = CreateObject( "MSComDlg.CommonDialog" )
If Err Then
MsgBox "This script requires COMDLG32.OCX." & vbCrLf & vbCrLf & "Please make sure it is installed and registered.", , "COMDLG32 not registered"
Else
objDialog.MaxFileSize = 260
objDialog.Flags = OFN_EXPLORER Or OFN_LONGNAMES Or OFN_CREATEPROMPT Or OFN_HIDEREADONLY
objDialog.InitDir = wshShell.CurrentDirectory
objDialog.DefaultExt = "vbs"
objDialog.Filter = "VBScript files|*.vbs"
objDialog.ShowSave
FileSaveDialog = objDialog.FileName
End If
Set wshShell = Nothing
Set objDialog = Nothing
End Function
page last modified: 2024-04-16; loaded in 0.0178 seconds