我想从文件资源管理器中复制选定的图片。它必须是文件资源管理器,因为我需要在选择图片之前将它们可视化。我找到了这个子:
Sub DetermineTheSelectedFiles()
'It needs `Microsoft Internet Controls`. Take care of adding this reference!
Dim ExpWin As SHDocVw.ShellWindows, CurrWin As SHDocVw.InternetExplorer
Set ExpWin = New SHDocVw.ShellWindows
For Each CurrWin In ExpWin
If Not CurrWin.Document Is Nothing Then
If Not CurrWin.Document.FocusedItem Is Nothing Then
Debug.Print CurrWin.Document.FocusedItem.Path: Stop
End If
End If
Next CurrWin
End Sub
不幸的是,我只得到最后选择的图片。 你能帮助我吗 ? 提前致谢。 丹尼尔
我修改了您的代码以获取选定的文件名;
Sub DetermineTheSelectedFiles()
'It needs `Microsoft Internet Controls`. Take care of adding this reference!
Dim ExpWin As SHDocVw.ShellWindows, CurrWin As SHDocVw.InternetExplorer, objItems As Object, i As Integer
Set ExpWin = New SHDocVw.ShellWindows
For Each CurrWin In ExpWin
If Not CurrWin.Document Is Nothing Then
If Not CurrWin.Document.FocusedItem Is Nothing Then
Set objItems = CurrWin.Document.SelectedItems
For i = 0 To objItems.Count - 1
Debug.Print objItems.Item(CLng(i)).Name
Next
End If
End If
Next
End Sub