Excel VBA打开和关闭文件夹
问题描述:
所以我知道如何在excel vba宏中打开文件夹,但是我也希望能够将其关闭.有什么想法吗?这是我用来打开文件夹的内容:
So I know how to open a folder within an excel vba macro, but I want to be able to close it as well. Any thoughts? This is what I'm using to open the folder:
Shell "Explorer.exe *file path*"
答
完成后,您可以使用存储在 vPID
中的进程ID终止应用程序.您要做的就是使用相同的 Shell函数
调用 TaskKill
命令.
You can use the Process ID, stored in vPID
, to kill the application when you’re done with it. all you have to do is invoke the TaskKill
command with the same Shell function
.
Dim vPID As Variant
vPID = Shell "Explorer.exe *file path*"
'Perform actions here
'// Kill file
Call Shell("TaskKill /F /PID " & CStr(vPID))