简体   繁体   中英

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. 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. 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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM