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

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,367
Office Version
  1. 365
Platform
  1. Windows
Why not just use GetOpenFilename to get the filename?
 
Upvote 0

Fahrvergnugen

New Member
Joined
Mar 21, 2005
Messages
33
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,195,670
Messages
6,011,073
Members
441,580
Latest member
BornholmerBjarne

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
Top