ADawn
asked on
Filter files with these extensions (File Dialog Box)
Hi again,
VB6 (sp4) ADO
I have two concerns. I want to display all files with these extensions: *.htm and *html in my file dialog box, and I want to check to see if the proper file extension was selected before I save its location to the Windows registry. Thanks for your help (as always).
With frmOptions.cd_Options
.DialogTitle = "Connect to application's back-end database."
.InitDir = "C:\DS3VB6\DS3_DATA\"
.FileName = "" 'App_BackEndDBName
.Filter = "Access (*.mdb)| *.mdb"
.CancelError = True 'Causes an error if user clicks on cancel
.ShowOpen
End With
'Remember that the file names are case sensitive
Do While UCase(Right(Trim(frmOption s.cd_Optio ns.FileNam e), Len("DS3DATA.MDB"))) <> "DS3DATA.MDB"
MsgBox "You are trying to link to the wrong file.", vbCritical, App.Title
frmOptions.cd_Options.Show Open
Loop
App_InventoryPath = Trim(frmOptions.cd_Options .FileName)
frmOptions.txtInventoryPat h = App_InventoryPath
'Save the Database location
SaveSetting App.Title, "App_Elements", "InventoryPath_DB", App_InventoryPath
-ADawn
VB6 (sp4) ADO
I have two concerns. I want to display all files with these extensions: *.htm and *html in my file dialog box, and I want to check to see if the proper file extension was selected before I save its location to the Windows registry. Thanks for your help (as always).
With frmOptions.cd_Options
.DialogTitle = "Connect to application's back-end database."
.InitDir = "C:\DS3VB6\DS3_DATA\"
.FileName = "" 'App_BackEndDBName
.Filter = "Access (*.mdb)| *.mdb"
.CancelError = True 'Causes an error if user clicks on cancel
.ShowOpen
End With
'Remember that the file names are case sensitive
Do While UCase(Right(Trim(frmOption
MsgBox "You are trying to link to the wrong file.", vbCritical, App.Title
frmOptions.cd_Options.Show
Loop
App_InventoryPath = Trim(frmOptions.cd_Options
frmOptions.txtInventoryPat
'Save the Database location
SaveSetting App.Title, "App_Elements", "InventoryPath_DB", App_InventoryPath
-ADawn
er, change the ...<> "HTML" Or Right$... to ...<> "HTML" And Right$...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
.Filter = "HTML Files (*.HTML, *.HTM)|*.html;*.htm"
To check the type (place this right after the line of code to show the dialog:
If Right$(UCase(CommonDialog1
MsgBox "Invalid Selection!", vbCritical, "Error"
Exit Sub
Else
'Write to registry
End If