Excel vba can';t发布winword.exe

Excel vba can';t发布winword.exe,excel,vba,Excel,Vba,我正在打开多个Word文档以删除其中的保护。 所以我的代码基本上是这样做的,如果用户选择输入密码,那么: 瓦勒尔=6 并且pwd被设置为特定值。 我的问题是,即使我这样做:set WdApp=nothing,它仍然不会释放winword.exe进程 Do While Len(F) > 0 If F = nom_fichier Then 'file name nom_original = chemin & "\" &

我正在打开多个Word文档以删除其中的保护。 所以我的代码基本上是这样做的,如果用户选择输入密码,那么: 瓦勒尔=6 并且pwd被设置为特定值。 我的问题是,即使我这样做:set WdApp=nothing,它仍然不会释放winword.exe进程

Do While Len(F) > 0
    If F = nom_fichier Then                     'file  name 
        nom_original = chemin & "\" & F                     'path
        nom_copie = repertoire_cible & "\" & nom_fichier                'copy of a file
        nom_modifie = repertoire_cible & "\" & nom_en_preparation       'rename of file
        If Dir(nom_original, vbDirectory) = vbNullString Then           
            GoTo fichier_non_trouve
        End If
        If Not Dir(nom_modifie, vbDirectory) = vbNullString Then                                GoTo fichier_deja_existant:
        End If
        FileCopy nom_original, nom_copie      'file copy
        Name nom_copie As nom_modifie         ' file rename
        If valeur = 6 Then                      'protection removal
           Set WdApp = CreateObject("Word.Application")
           Set WdApp = Documents.Open(nom_modifie)
           If Not WdApp.ProtectionType = -1 Then                                            WdApp.Unprotect pwd
                WdApp.Close True
           Else
               WdApp.Close True
           End If

           Set WdApp = Nothing
        End If
        GoTo fichier_copier:
    End If                                   'on copie le fichier dans le dossier en préparation
    F = Dir()
Loop
所以在这一点上,因为我调用了Set-WdApp=nothing,我不明白为什么它不释放winword.exe。
任何类型的帮助都将非常感谢

独立地保留对应用程序和文档的引用并
。退出应用程序:

Set WdApp = CreateObject("Word.Application")
Set WdDoc = Documents.Open(nom_modifie)

 ... use wdDoc

WdDoc.close True
WdApp.Quit
但是为什么不在循环外创建
WdApp
,并根据需要打开文档,在完成后退出应用程序呢