[英]Excel VBA Open and close a Folder
So I know how to open a folder within an excel vba macro, but I want to be able to close it as well. 因此,我知道如何在excel vba宏中打开文件夹,但我也希望能够将其关闭。 Any thoughts? 有什么想法吗? This is what I'm using to open the folder: 这是我用来打开文件夹的内容:
Shell "Explorer.exe *file path*"
You can use the Process ID, stored in vPID
, to kill the application when you're done with it. 完成后,您可以使用存储在vPID
的进程ID vPID
应用程序。 all you have to do is invoke the TaskKill
command with the same Shell function
. 您要做的就是使用相同的Shell function
调用TaskKill
命令。
Dim vPID As Variant
vPID = Shell "Explorer.exe *file path*"
'Perform actions here
'// Kill file
Call Shell("TaskKill /F /PID " & CStr(vPID))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.