0

有谁知道为什么每次循环 for next 循环时,我都会在任务管理器中运行 word 的后台进程?谢谢。

Try
        For Each element In Raneeded
            If Not String.IsNullOrEmpty(element) Then
                Dim OpenRA = New Microsoft.Office.Interop.Word.Application

                docname = d(CInt(element)) & ".docx"
                OpenRA.Documents.Open(folderpath & docname)

                OpenRA.Visible = False
                Dim opened1 = OpenRA.ActiveDocument

                Dim RAtable As Word.Table = opened1.Tables(1)
                RAtable.Cell(1, 1).Range.Text = "Site Address: " & address
                opened1.Close()
            End If
        Next
    Catch ex As Exception
        MsgBox(ex.Message & " Please contact your system Administrator, quoting these details.")
    End Try
4

1 回答 1

1

您关闭文档,但从不关闭单词 aplication OpenRA,要么在循环之外定义它,然后在最后关闭它,要么在关闭文档时关闭每个

 opened1.Save()
 OpenRA.Quit()
于 2013-04-12T16:42:17.960 回答