Word Documents.Count Is incorrect from MS Access 2016

I have an MS Access application that spawns a single Word Document at any one time. However the "Word.Application" object doesnt seem to be closing properly, before the next attemt to open a different document (i'll work that out). It errors when attempting to return to a document previously opened, reporting it to be already open. Well indeed Process Explorer reveals it is indeed still open. So I was intending to count the number of docs open and if there were none, close the Word Application. But in the course of trying to get it to close properly I discover that if I do this:

Dim objWord As word.application
Dim doc As Object

On Error GoTo ErrorHandler

    Set objWord = CreateObject("Word.Application")
    objWord.visible = False
    Set doc = objWord.Documents.Open(wordDocFilespec) ... 

Inspecting the watch window objWord.Documents.Count is 1, as you might expect and it was 0 prior to the "Open" except I already have other Word documents not related to this application Open on the desktop! Is it not supposed to Count the total number of Word docs open, rather than just the apps opened via this object declaration?

链接地址: http://www.djcxy.com/p/55928.html

上一篇: 在C#中将后期绑定到XAML / Store应用程序中的Word控件

下一篇: Word Documents.Count在MS Access 2016中不正确