Announcement

Collapse
No announcement yet.

How to create Userform in excel to open particular file location

Collapse
This topic is closed.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to create Userform in excel to open particular file location



    Hi All,

    I am working on a project where i am having 8 excel files saved at diffrent location so i want to create userform which will open particular file location and from that user can select the file which he want and then can go further. so i need a coding so that user will be prompt 8 times with file location. for eg. once user select particular file from location then again this code route him to select next file from file location. is it possible??

    I tried using below code but in this code when i run userform file is not opening but when i run this code mannually by pressing F8 desired file is opening i dont know what is glitch in this ?? is there any othe code or method which can help me ?? another problem i am facing is not able to understand how to repeat this steps again to open another file using this code??

    Code:
    Private Sub Commandbutton1_Click()
    Dim f As FileDialog
    Set f = Application.FileDialog(msoFileDialogFilePicker)
    With f
    MsgBox "select Diamond file"
    .Title = "Select a Diamond file..."
    .InitialFileName = "H:\Working\macro"
    .ButtonName = "Select"
    '.Filters.Add "Excel Files", "*.xls", 1
    .AllowMultiSelect = False
    If .Show = -1 Then
    ' Below line will put the selected file path in the textbox
    TextBox1.Text = .SelectedItems.Item(1)
    Shell "cmd /c " & """" & .SelectedItems(1) & """"
    End If
    End With 'Reset default file path for Open/Save dialogs
    'Dim dfp As String
    'dfp = Application.DefaultFilePath
    'ChDrive Left(dfp, 1)
    'ChDir Application.DefaultFilePath
    'Set f = Nothing
    End Sub
    if someone know any answer help me with this ... cause if someone can crack this i can save arround daily 4 hrs of my work

    Thanks in advance !!

    Suyog patil
    Last edited by suyogpatil; May 22nd, 2013, 22:56. Reason: as suggested by forum rules

  • #2
    Re: How to create Userform in excel to open particular file location

    Please edit your post to include code tags around the code listing. Code tags format and colourise the code making it easier to read and so follow the logic. Code tags are required by the rules you agreed to when you joined the forum and must be used regardless how long, or short, the code is.

    To add code tags, edit your message, highlight the code and click the '#' button on the edit panel toolbar.

    Comment


    • #3
      Re: How to create Userform in excel to open particular file location

      ohhhk got it thanks i am new to this forum so not aware about all rules

      Comment


      • #4
        Re: How to create Userform in excel to open particular file location

        You checked to box to say you agreed to them when you joined... !

        Might suggest you click the 'Rules' link under your name in a post, and have a read. It'll take all of a minute or 2.

        Comment


        • #5


          Re: How to create Userform in excel to open particular file location

          Hi can someone help me in this ... Thanks in advance !!

          Comment

          Working...
          X