GFCDSaveFile/GFCDSaveFile.frm

VERSION 5.00
Object = "{F9043C88‑F6F2‑101A‑A3C9‑08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   3225
   ClientLeft      =   60
   ClientTop       =   315
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3225
   ScaleWidth      =   4680
   StartUpPosition =   3 'Windows‑Standard
   Begin MSComDlg.CommonDialog GFCDSaveFileCommonDialog
      Left            =   60
      Top             =   60
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton Command1
      Caption         =   "Save File"
      Height          =   315
      Left            =   2700
      TabIndex        =   0
      Top             =   2820
      Width           =   1875
   End
   Begin VB.Label Label1
      Height          =   1755
      Left            =   120
      TabIndex        =   1
      Top             =   840
      Width           =   4455
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'(c)2000 by Louis.

Private Function GFCDSaveFile(ByVal CommonDialogTitle As StringByVal CommonDialogDefaultPath As StringByVal CommonDialogFileType As String) As String
    On Error GoTo Error: 'important (if CommonDialog is not available); make user select a file for saving
    GFCDSaveFileCommonDialog.DialogTitle = CommonDialogTitle
    GFCDSaveFileCommonDialog.Flags = cdlOFNHideReadOnly + cdlOFNExplorer 'hide 'read only' check box and allow resizing CommonDialog
    GFCDSaveFileCommonDialog.Filter = "Default Files|" + CommonDialogFileType + "|All Files|*.*"
    GFCDSaveFileCommonDialog.FilterIndex = 1
    GFCDSaveFileCommonDialog.InitDir = CommonDialogDefaultPath
    On Error GoTo 0
    On Error GoTo CancelError:
    GFCDSaveFileCommonDialog.CancelError = True
    GFCDSaveFileCommonDialog.ShowSave
    GFCDSaveFile = GFCDSaveFileCommonDialog.filename
    Exit Function
Error:
    MsgBox "internal error in GFCDSaveFile(): Common Dialog not available !" + Chr(10) + "Check if related dlls are available.", vbOKOnly + vbExclamation, "GDCDRequestFile" 'use original function name as application name
    GFCDSaveFile = InputBox("enter file name:", CommonDialogTitle)
    Exit Function
CancelError:
    GFCDSaveFile = ""
    Exit Function
End Function

Private Sub Command1_Click()
    Label1.Caption = GFCDSaveFile("Save a File using Common Dialog", App.Path, "*.bmp")
End Sub


[END OF FILE]