运行程序后的多个Word实例

时间:2013-04-12 15:47:27

标签: vb.net ms-office

有没有人知道为什么我会在每次循环到下一个循环时在任务管理器中获得运行单词的后台进程?感谢。

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

1 个答案:

答案 0 :(得分:1)

你关闭了doc,但是从不关闭aplication这个词,要么在循环外定义它,要么在结束时关闭它,要么在关闭doc时关闭它们

 opened1.Save()
 OpenRA.Quit()
相关问题