Fahrvergnugen
New Member
- Joined
- Mar 21, 2005
- Messages
- 33
Is there a way to have the MS Common Dialog control available without adding it to a form. I would like to have the user select a particular database and save the path using MS Common Dialog Open (which I have successfully done). The only way I have figured out how to do this is by dropping the Common Dialog control on a form, but I have no use for the form other than for this reason. Seems silly to have a form with only the Common Dialog control on it.
The following is my code (referencing cdlCommonDialog, which is the MS Common Dialog control that I have on my form):
Private Sub GetDatabasePath()
On Error GoTo ErrorHandler
On Error GoTo ErrorHandler
Dim intFileNum As Integer
'opens common dialog that allows the user to open the budget
'database and returns the path where it is located
intFileNum = FreeFile
With cdlCommonDialog
.CancelError = True
.DialogTitle = "Please locate the Biblio.mdb database"
.Filter = "Microsoft Database Files|*.mdb|All Files|*.*"
.Flags = cdlOFNFileMustExist
.InitDir = ActiveWorkbook.Path
.ShowOpen
mstrDatabasePath = .Filename
End With
Exit Sub
ErrorHandler:
MsgBox "Open File Cancelled", vbInformation, "User Cancelled"
End Sub
The following is my code (referencing cdlCommonDialog, which is the MS Common Dialog control that I have on my form):
Private Sub GetDatabasePath()
On Error GoTo ErrorHandler
On Error GoTo ErrorHandler
Dim intFileNum As Integer
'opens common dialog that allows the user to open the budget
'database and returns the path where it is located
intFileNum = FreeFile
With cdlCommonDialog
.CancelError = True
.DialogTitle = "Please locate the Biblio.mdb database"
.Filter = "Microsoft Database Files|*.mdb|All Files|*.*"
.Flags = cdlOFNFileMustExist
.InitDir = ActiveWorkbook.Path
.ShowOpen
mstrDatabasePath = .Filename
End With
Exit Sub
ErrorHandler:
MsgBox "Open File Cancelled", vbInformation, "User Cancelled"
End Sub