Hi..
Is it possible to make a document invisible after it´s open? I would like to keep it in memory but not reachable to the user.
Making the document view(s) invisible is not what I´m looking for. I need to clear/close/delete all views WITHOUT closing the document..
( So it has the same state as if opened through API with the visible parameter set to false, e.g. Document.VIews.Count = 0
Offhand I don't think there is a way to make a document invisible once it's open...
But you can open a document invisible with the "Open As Visible Boolean" argument False of the Documents method Open
ThisApplication.Documents.Open(oFile, False)
Hi Jonathan
Thx for your reply. And yes: Close > Open was my workaround before, but this was one of those questions that answered it self when asked.
I believed the number in the GUI indicating "Open Documents in Session" showed all documents in memory, but an afterthought made me check it out, and to my happy surprise:
Closing the last view on a document does NOT close the document. ( hence making it invisible )
This thread was my starting point, but I thought it wasn´t working on wrong assumptions as noted above
Actually I´m not correct in my statement above:
As far as my experiments go I´m concluding that the Document is CLOSED when the documents last view is closed, but it is not TERMINATED. Thus it is still in memory, invisible, and available through API as was what I was looking for.
Sorry for the clutter 😉
I'm finding it difficult to manage documents when applying a mix of open invisible, release reference, view add, view close, document close and document close all. The following are some observations I've made.
When using open invisible we can call release reference afterwards so it will be closed with other non-referenced documents at an appropriate time. This seems to be implemented as a simple flag rather than a reference count and can't be used to keep a document open. Similarly, we shouldn't call release reference on a document that was already open.
Adding a view allows us to activate a previously invisible document and execute some commands such as Vault check in/out. Closing the view also closes the document and invalidates our reference to it. (As per API documentation: "If only one view exists for a document and the Close method is called it will also cause the Document to close.")
If we have added a view we need to leave it as long as we need the document open. However, now our release reference will not allow our document to close with non-referenced documents. It seems we are forced into finding an appropriate time to close the document.
Regards,
cadull
I agree that the API implementation in this matter leaves some space for improvement.
On my side there is lots of space for improving my feedback in this topic I was doing some shotgun experiements and forgot to unsubscribe a certain eventhandler so I´m sad to say that I´m back to my initial workaround & the solution Jonathan also refered to. Your reference to the API documentation is sadly absolutely correct : the document is closed AND terminated when the last view is closed.
my wish for an easy API implementation would be changing the ReleaseReference method with a "KeepOpen" boolean property, preventing the document to close when the last view is closed if set to true, and making it act as the ReleaseReference() when set to false.
On the good side,opening the document again in the OnClose eventhandler only takes a few milliseconds, and it doesn´t seem to trigger the OnOpen event.