关闭特定的pdf文件

时间:2014-05-09 19:41:54

标签: excel-vba vba excel

我使用此功能关闭adobe reader

Sub TerminateProcess()
Dim strTerminateThis As String
Dim objWMIcimv2 As Object
Dim objProcess As Object
Dim objList As Object
Dim intError As Integer

'Process to terminate
strTerminateThis = "AcroRd32.exe"

'Connect to CIMV2 Namespace
Set objWMIcimv2 = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")

'Find the process to terminate
Set objList = objWMIcimv2.ExecQuery("select * from win32_process where name='" & strTerminateThis & "'")

'Terminates a process and all of its threads.
For Each objProcess In objList
    intError = objProcess.Terminate
Next

Set objWMIcimv2 = Nothing
Set objList = Nothing
Set objProcess = Nothing
End Sub

是否可以编辑它以便我可以关闭特定的pdf文件而不是所有文件?

提前感谢你。

0 个答案:

没有答案