Results 1 to 4 of 4

Want to automate the msofiledialogfolderpicker

Threaded View

  1. #1
    Registered User
    Join Date
    05-20-2010
    Location
    rotherham
    MS-Off Ver
    Excel 2010
    Posts
    16

    Want to automate the msofiledialogfolderpicker

    Hi I love this code but there are times when i don't want the user to actually pick a folder. At the moment when running the code you are prompted to "select a folder to list files from" I want to hard code in the folder name so at the click of a button it will show all the current files in C drive. Can anyone help please. I have tried different codes but this is the most user friendly as it shows the files names very quickly. I hope this makes sense

    Regards
    Christine
    Sub GetFileNames()
    Dim xRow As Long
    Dim xDirect$, xFname$, InitialFoldr$
    InitialFoldr$ = "C:\"
    With Application.FileDialog(msoFileDialogFolderPicker)
    .InitialFileName = Application.DefaultFilePath & "\"
    .Title = "Please select a folder to list Files from"
    .InitialFileName = InitialFoldr$
    .Show
    If .SelectedItems.Count <> 0 Then
    xDirect$ = .SelectedItems(1) & "\"
    xFname$ = Dir(xDirect$, 7)
    Do While xFname$ <> ""
    ActiveCell.Offset(xRow) = xFname$
    xRow = xRow + 1
    xFname$ = Dir
    Loop
    End If
    End With
    End Sub
    Last edited by jacc14; 12-07-2017 at 08:51 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Application.FileDialog(msoFileDialogFolderPicker) looping?
    By Andrew Entee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-10-2017, 05:57 PM
  2. Replies: 8
    Last Post: 11-01-2016, 06:23 PM
  3. [SOLVED] end if cancel clicked on .FileDialog(msoFileDialogFolderPicker).Show
    By dedark05 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-21-2016, 09:35 PM
  4. Show Files in Folder using Application.FileDialog(msoFileDialogFolderPicker)
    By rtcwlomax in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-05-2015, 09:53 AM
  5. VBA msoFileDialogFolderPicker in Windows 7
    By jruixls in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-15-2011, 08:19 AM
  6. Unloading Directory Path using msoFileDialogFolderPicker
    By lilanngel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-07-2010, 04:03 PM
  7. FileDialog(msoFileDialogFolderPicker) not using the current direct
    By nx3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-08-2006, 08:25 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1