Results 1 to 4 of 4

Thread: Default open location from combo box date

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    48

    Default open location from combo box date

    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

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Default open location from combo box date

    Sure
    You can change the default file path every time the combobox is changed.

    VB Code:
    1. Const sBASE_PATH As String = "C:\project\"
    2.  
    3. Private Sub ComboBox1_Change()
    4. Dim sMonth As String
    5.  
    6.     sMonth = Me.ComboBox1.Value
    7.     Application.DefaultFilePath = sBASE_PATH & sMonth
    8. End Sub
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    48

    Re: Default open location from combo box date

    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

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Default open location from combo box date

    Quote Originally Posted by c19h28O2
    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.
    VB Code:
    1. Public Const sBASE_PATH As String = "C:\project\"
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width