none
Userform and fdlFileDialogue RRS feed

  • Question

  • Hello,

    I'm familiar with UserForms and with FileDialogue.  However, I've never combined them. 

    I have a UserForm with some radio button and list boxes that are working fine.  Now, I need to add a few fdlFileDialogue boxes so that I can have the user choose a presentation from a given directory.  The code below generates a separate dialogue box.  I need this to be contained within the UserForm.  How do I setup a msoFileDialog in a UserForm?

    'Set fdlFileDialogue to contain the full name of the selected item
    'With...End blocks need an object, such as File Dialogue, or a variant
    Set fdlFileDialogue = Application.FileDialog(msoFileDialogFilePicker)
        
    ' Use a With...End With block to reference the FileDialog object.
    With fdlFileDialogue
    '   Set the initial view of the dialog box to the Details view.
        .InitialView = msoFileDialogViewDetails
    '   Do NOT allow user to make multiple selections in dialog box
        .AllowMultiSelect = False
    '   Set the title of the dialog box.
        .Title = "Please select ONLY ONE Presentation
    '   Clear out the current filters, and add our own.
        .Filters.Clear
        .Filters.Add "Powerpoint Files", "*.pptx", 1
    '   Set the initial folder to strPPT_EditedPath
        .InitialFileName = strPPT_EditedPath
    '   Assign varSelectedPresentation the chosen File (.InitialFileName)
        varSelectedPresentation = .InitialFileName
    '   Use the .Show method to display FilePicker and return the user's action.
    '   If the user selected a file, then .Show would equal True
    '   If the user pressed "Cancel" then .Show would equal "False"
        If .Show = True Then

    '       Open the presentation and copy it
    '       Assign varSelectedPresentation the chosen File: SelectedItems(1)
            varSelectedPresentation = .SelectedItems(1)

    And the code continues

    Thanks very much for looking at this.

    Thursday, April 9, 2015 2:50 AM

Answers

  • Re:  "How do I setup a msoFileDialog in a UserForm?"

    You can't.

    Why not...
      hide the userform
      show the file dialog
      show the userform again with the name of the chosen file displayed on the form?
    '---

    Jim Cone
    Portland, Oregon USA
    https://goo.gl/IUQUN2 (Dropbox)
    (free & commercial excel add-ins & workbooks)

    Thursday, April 9, 2015 4:38 AM
  • There is no built-in way to do that. You'd have to build your own file dialog from controls on the userform. In my opinion, that would be more work than it's worth - I'd display the native FileDialog, i.e. as a separate popup dialog.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Thursday, April 9, 2015 4:39 AM

All replies

  • Re:  "How do I setup a msoFileDialog in a UserForm?"

    You can't.

    Why not...
      hide the userform
      show the file dialog
      show the userform again with the name of the chosen file displayed on the form?
    '---

    Jim Cone
    Portland, Oregon USA
    https://goo.gl/IUQUN2 (Dropbox)
    (free & commercial excel add-ins & workbooks)

    Thursday, April 9, 2015 4:38 AM
  • There is no built-in way to do that. You'd have to build your own file dialog from controls on the userform. In my opinion, that would be more work than it's worth - I'd display the native FileDialog, i.e. as a separate popup dialog.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Thursday, April 9, 2015 4:39 AM
  • Thanks Jim.  I'm glad I didn't waste time trying.

    Phil

    Thursday, April 9, 2015 11:17 AM
  • Thanks Hans,

    Glad I didn't waste time trying.

    Thursday, April 9, 2015 11:18 AM