vba,尝试更改打开的文件夹地址

时间:2016-07-14 20:05:11

标签: excel windows vba shell explorer

基本上我想打开一个Windows资源管理器并浏览打开的窗口。 更改打开的窗口本身的路径。 我想办法获得当前的窗口路径,虽然它没有帮助我很多:

Set abc = CreateObject("Shell.Application")
for each cell in abc.windows - gives us all the opened windows
 if cell.name = "File Explorer" 'etc

以及如何打开一个窗口:

Application.ThisWorkbook.FollowHyperlink Address:="D:\", NewWindow:=True

有更多方法可以做到这一点,在shell中这样做:

Shell("explorer.exe " & "c:\", vbNormalFocus)

基本上我的整个问题是如何更改打开的窗口地址,我的意思是,我可以将它作为shell.application的对象找到,我该如何从这里继续?

另外,我如何制作一个看不见的开放式资源管理器? ty提前。

1 个答案:

答案 0 :(得分:1)

控件是WebBrowser控件。

添加Microsoft Internet Controls参考库。

对我来说,它是Windows Explorer而不是File Explorer所以我在我的代码中使用了这个,但如果你的代码不同,只需使用你的所有内容。

Sub test()
Dim abc As Object
Dim Cell As Variant

Set abc = CreateObject("Shell.Application")
For Each Cell In abc.Windows

    If Cell.Name = "Windows Explorer" Then
        Cell.Navigate "C:\" 'to go to different address
        cell.Visible = True 'to toggle between visible and not  
    End If

Next Cell


End Sub
相关问题