Userform TreeView - Drag and Drop files from Explorer and Outlook attachements

kpasa

Board Regular
Joined
Nov 20, 2015
Messages
82
I have a userform with a TreeView being used as a "Drag and Drop" file input. The goal is to have the userform automatically accept that file and copy it to a specified folder.
So far i have this code in my userform_activate:
Code:
TreeView1.OLEDropMode = ccOLEDropManual
TreeView1.OLEDragMode = ccOLEDropManual

And then the 'Private Sub TreeView1_OLEDragDrop' event
Code:
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)
    MsgBox StrPath
End Sub

For this proof of concept, I have it only displaying the file's path. I will eventually get to the rest of the code. So far it works fine with a file from File Explorer.

My problem is that I often am filing attachments from outlook emails. But when try to drag an attachment over, i get the following error:
"Run-time error '461': Specified format doesn't match format of data"

Any thoughts on how I can address this error?
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top