I am trying to close an array of Word documents, some of which may have already been closed by the user.
Dim arrDoofDocs As Integer
Dim aDoc As Document
aDocArray has the documents that were open when we started but some of which the user may have closed. The code works if the docs are all open
As you can see I have tried On Error and If ... Nothing but to no avail. It hits the "object has been deleted error". What's the correct code?
For i = 1 To arrNoofDocs
Set aDoc = aDocArray(i)
'On Error GoTo SkipClose
'If aDoc Is Nothing Then GoTo SkipClose ' Check if doc is open. User might have closed it
'aDoc.Close
If Not aDoc Is Nothing Then aDoc.Close ' Check if doc is open. User might have closed it
SkipClose:
Next
Thanks
John