
Originally Posted by
bambaataa
1. When I run the code above, the email is created and the fields are filled out (with
email1@domain.com, etc.); however, the active file is
not attached. Any suggestions as to what may be going wrong?
In my tests (Notes 6.5) the file is attached, but isn't visible to the user until they send or close and reopen the email. However, I can understand why you would want the attachment to be visible in the open document as confirmation that the file has been attached, so I've spent some time investigating and writing the code to achieve this. Part of the solution involves the VBA SendKeys command, which isn't reliable so the solution might not always work for you, however it always worked in my tests.
2. Occasionally (maybe 20% of the time), I get this error message: "Run-time Error '91': Object variable or With block variable not set." The error occurs on the line ".FieldSetText "EnterSendTo", "email1@domain.com" -- any idea what might be causing this and why it only happens some of the time?
That error must mean that the NUIDocument object is undefined (Nothing). It could be caused by VBA attempting to access the new document before the Lotus Notes UI has created it. I've added a check which loops until NUIDocument is not Nothing, waiting for up to 10 seconds.
Here is the complete code:
Bookmarks