VBA to open and CLOSE windows explorer inside a vault path
Posted: Mon Jun 24, 2024 7:04 am
I am trying to open a vault path from a excel macro. explorer opens as a normal window without the green folders and the pdm tabs and showing the normal yellow folders and files.
I am alredy logged into the pdm and using the standard api calls to open explorer.
Any help? what method should I use to open (and close) an explorer window pointing a vault path?
UPDATE
I was trying it from excel VBA using
I was suggested to use instead
the shell indeed opens explorer correctly inside the vault, but then I need to perform another operation:
search every explorer window and close the one inside the vault.
With the code below that would not be a problem and it works for paths like c:\ or c:\windows
When trying that code with an explorer window opened inside the vault I get an error error 445 on explorerWindow.Document.Folder.Self.Path
The path supplyed is valid but the object does not support the path property apparently.
Testing on Win11 and Excel 2016 64 bit.
I am alredy logged into the pdm and using the standard api calls to open explorer.
Any help? what method should I use to open (and close) an explorer window pointing a vault path?
UPDATE
I was trying it from excel VBA using
Code: Select all
ThisWorkbook.FollowHyperlink strDirectory, "", False, False
Code: Select all
Dim vault As EdmVault5
Set vault = New EdmVault5
vault.LoginAuto "VAULTNAMEHERE", 0
Dim location As String
Shell "C:\WINDOWS\explorer.exe """ & vault.RootFolderPath & "", vbNormalFocus
search every explorer window and close the one inside the vault.
With the code below that would not be a problem and it works for paths like c:\ or c:\windows
Code: Select all
Sub CloseExplorerWindowByPath(targetFolderPath As String)
Dim explorerWindow As Object
Dim shellWindows As Object
Set explorerWindow = CreateObject("Shell.Application").Windows
' Loop through each Explorer window
For Each explorerWindow In shellWindows
' Check if the window's document folder path matches the target path
If InStr(1, explorerWindow.Document.Folder.Self.Path, targetFolderPath, vbTextCompare) > 0 Then
' Close the matching window
explorerWindow.Quit
Exit For
End If
Next explorerWindow
End Sub
The path supplyed is valid but the object does not support the path property apparently.
Testing on Win11 and Excel 2016 64 bit.