Hello Gurus,
I have below code which allows me to get file name by opening the folder and selecting the file. Is there a way from me to simply drag and drop the file then the form will display the file path?
Thank you for help.
I
I have below code which allows me to get file name by opening the folder and selecting the file. Is there a way from me to simply drag and drop the file then the form will display the file path?
Thank you for help.
I
Code:
Sub UserForm_Initialize()
' TreeView1.OLEDropMode = ccOLEDropManual
Me.TreeView1.OLEDragMode = ccOLEDragManual
End Sub
Private Sub TreeView1_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
' Dim StrPath As String
' StrPath = Data.files(1)
Set myFolder = Application.FileDialog(msoFileDialogFolderPicker)
With myFolder
.Title = "Choose Folder"
.AllowMultiSelect = False
If .Show <> -1 Then
Exit Sub
End If
FolderSelected = .SelectedItems(1)
End With
MsgBox "You Selected:" & FolderSelected
End Sub