Selecting a folder using msoFileDialogFolderPicker
<p>To copy a Pictures/Images a code is written, To copy images i have to set the folder path, now i am currently manually setting the folder path, As the code is to be used by many user i want to give a option for user to select the folder. </p>

<p><strong>Application.FileDialog(msoFileDialogFolderPicker)</strong> Vba has got this method to set folder path, correct me if am wrong.</p>

<p>Now i have to implement the above method to select folder by user for below code.</p>

<pre><code>    Private Sub CommandButton1_Click()

Dim rgTarget As Range
Dim RowI As Long, ColumnI As Long

    Folderpath = "C:\Users\sandeep.hc\Pics"
    Set fso = CreateObject("Scripting.FileSystemObject")
    NoOfFiles = fso.GetFolder(Folderpath).Files.Count
    Set listfiles = fso.GetFolder(Folderpath).Files
    For Each fls In listfiles
       strCompFilePath = Folderpath &amp; "\" &amp; Trim(fls.Name)
        If strCompFilePath &lt;&gt; "" Then
            If (InStr(1, strCompFilePath, "jpg", vbTextCompare) &gt; 1 _
            Or InStr(1, strCompFilePath, "jpeg", vbTextCompare) &gt; 1 _
            Or InStr(1, strCompFilePath, "png", vbTextCompare) &gt; 1) Then
    RowI = 29
    ColumnI = ColumnI + 1
    Set rgTarget = Cells(RowI, ColumnI)
    Application.ActiveSheet.Shapes.Addpicture strCompFilePath, False, True, rgTarget.Left, rgTarget.Top, 875, 400
    ColumnI = ColumnI + 17
    End If

End If
Next

End Sub
</code></pre>

<p>In above code am setting folder path manually in code.</p>

<p><strong>Folderpath = "C:\Users\sandeep.hc\Pics"</strong></p>

<p>Instead i want it by user like below part of code,</p>

<p><strong>Application.FileDialog(msoFileDialogFolderPicker)</strong></p>

<p>help is needed to implement msoFileDialogFolderPicker to above code.</p>