Excel VBA打开和关闭文件夹 [英] Excel VBA Open and close a Folder
本文介绍了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))
这篇关于Excel VBA打开和关闭文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文