Subject: I think there may be some confusion about which document you’re working with in different circumstances
Anytime you’re using a uidoc, I think you had better put up a messagebox with the windowtitle and noteID of the uidoc, so that you know for sure which one you’re working with.
I haven’t tried it, but I would guess that the reason InPreviewPane returns False when used on a document in the embedded editor, is that the embedded editor is not a preview pane. There doesn’t seem to be a function to do this test.
However, I notice about documents in an embedded editor, that when the document opens it does not have focus. The containing document (with the embedded view and editor in it) has focus. Therefore, perhaps you could take advantage of the fact that there’s a difference between the currentDocument and the Source argument, to determine whether the document being opened, has focus. When it doesn’t, or is in the preview pane, is when you don’t want to write a log entry.
Sub LogEvent(Source As NotesUIDocument)
Dim ws As New NotesUIWorkspace
if Source.InPreviewPane Or Not (Source Is ws.CurrentDocument) Then
Exit Sub ' don't log unless doc is opened in its own window.
End If
…
This also suggests that the reason putting the code in the Initialize event works for documents in the embedded editor (does not log) is totally by accident. Once again here, the Initialize event reads the wrong document by mistake and sets the Postopen and Postsave events of the containing document rather than those of the document in the embedded editor. This means the events can still trigger at unintended times, e.g. if the document with the embedded elements is edited and saved.
Incidentally, I don’t know what your customer’s application is, but it strikes me as silly to log every time a user opens a document, only when its opened in its own window. Because I opened a document, that doesn’t mean I read that entire document. Or, just because I opened a document in the preview pane instead of its own tab, what’s to say I didn’t carefully read the whole document? I read my email, for instance, almost entirely in the preview pane. I read it, answer it, delete or file it, without ever opening it in its own tab. What does that log entry actually mean? It doesn’t tell you anything about whether the user actually read the document, forwarded it, printed it, sent it to wikiLeaks, or what have you.