Common Dialog Control

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
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Why not just use GetOpenFilename to get the filename?
 
Upvote 0
Thanks Norie. The reason I did not use GetOpenFileName is because I am still learning the Excel object model, so I did not know the function existed.
 
Upvote 0

Forum statistics

Threads
1,224,427
Messages
6,178,585
Members
452,859
Latest member
dallasazcat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top