PDA

Click to See Complete Forum and Search --> : Default open location from combo box date


c19h28O2
Feb 17th, 2006, 06:02 AM
Hi,

This relates to Excel VBA

I have 12 folders which are named Jan, Feb, March... etc. I also have a combo box with the months of the years in. Is it possible to select one of the folders depending on what month the user selects in the combo box, so if the user selects Feb, the default location in a file open dialog box would be C:\project\feb?

Thanks

C19

DKenny
Feb 17th, 2006, 08:19 AM
Sure
You can change the default file path every time the combobox is changed.

Const sBASE_PATH As String = "C:\project\"

Private Sub ComboBox1_Change()
Dim sMonth As String

sMonth = Me.ComboBox1.Value
Application.DefaultFilePath = sBASE_PATH & sMonth
End Sub

c19h28O2
Feb 17th, 2006, 09:27 AM
Hi,

Thanks for that - as a side do you know how to declare the sBASE_PATH to be viewable by all modules? i have a few procedures that refer to a database but would like to put the database path in one place.

Thanks

DKenny
Feb 17th, 2006, 09:33 AM
as a side do you know how to declare the sBASE_PATH to be viewable by all modules?

Add Public to the constant declaration

e.g.

Public Const sBASE_PATH As String = "C:\project\"