GFCDLoadFile/GFCDLoadFile.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 GFCDLoadFileCommonDialog
Left = 60
Top = 60
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton Command1
Caption = "Load 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 GFCDLoadFile(ByVal CommonDialogTitle As String, ByVal CommondialogDefaultPath As String, ByVal CommonDialogFileType As String) As String
On Error GoTo Error: 'important (if CommonDialog is not available); let user select a file
GFCDLoadFileCommonDialog.DialogTitle = CommonDialogTitle
GFCDLoadFileCommonDialog.Flags = cdlOFNHideReadOnly + cdlOFNExplorer 'hide 'read only' check box and allow resizing CommonDialog
GFCDLoadFileCommonDialog.Filter = "Default Files|" + CommonDialogFileType + "|All Files|*.*"
GFCDLoadFileCommonDialog.FilterIndex = 1
GFCDLoadFileCommonDialog.InitDir = CommondialogDefaultPath
On Error GoTo 0
On Error GoTo CancelError:
GFCDLoadFileCommonDialog.CancelError = True
GFCDLoadFileCommonDialog.ShowOpen
GFCDLoadFile = GFCDLoadFileCommonDialog.filename
Exit Function
Error:
MsgBox "internal error in GFCDLoadFile(): Common Dialog not available !" + Chr(10) + "Check if related dlls are available.", vbOKOnly + vbExclamation, "GDCDRequestFile" 'use original function name as application name
GFCDLoadFile = InputBox("enter file name:", CommonDialogTitle)
Exit Function
CancelError:
GFCDLoadFile = ""
Exit Function
End Function
Private Sub Command1_Click()
Label1.Caption = GFCDLoadFile("Request a File using Common Dialog", App.Path, "*.exe")
End Sub
[END OF FILE]