I'm encountering an error that is difficult to recreate. It almost always happens eventually, I just cannot recreate the conditions that cause it to occur so I cannot determine why it occurs.
What I'm Doing:
I'm copying data from a query to paste into an Outlook email. The data is SharePoint links (http addresses saved as Long Text to allow for >255 characters) so they can click on the links (which Outlook conveniently converts to the title of the document or folder referred to by just the address) to open the item in SharePoint. e.g., "These documents were approved by X. You can access them directly or open their folders to share with others. Etc. etc."
How I'm Doing It:
I have a command button called "Copy for Email" on a record. The record is the approval form data, and links to documents that were approved. My code for this button is (I had to manually type this over, as I cannot share confidential work data--so anything that would invalidate the code are likely typos--the code works, except when it doesn't):
Code:
Private Sub cmdExportforEmail()
With DoCmd.OpenQuery "qryApprovalsExport", acviewNormal, acEdit
.SelectObject acQuery, "qryApprovalsExport"
.RunCommand acCmdSelectAllRecords
.RunCommand acCmdCopy
.Close acQuery, "qryApprovalsExport", acSaveNo
End With
MsgBox "A data table of the SharePoint links for the documents in this approval was copied to your clipboard. It is ready to paste into an email.", vbInformation, "DATA TABLE EXPORT CREATED"
End Sub
What Happens - My Issue
Doing this pretty much always works the first time. I hit the button, I see the message, I paste into Outlook. All good. Sometimes it will work several times in a row, either with the same approval record, or different ones. At some point, however, I get the following when I try to paste into my Outlook. I get a pop up (like a message box) saying: Word has encountered a problem
Yes, it says "Word". I presume this is because Word is the underlying editor for html emails in Outlook.
What I've Done to Try to Figure this Out
- If I try to paste into Wordpad (plain text) I just get nothing. The cursor just flashes to acknowledge I pressed some buttons. This to me is an indication there is something wrong with what is residing in the Clipboard. Maybe it's corrupt? Maybe it's blank?
- So I used WindowsKey + V to bring up the Clipboard history. When I press the first entry, it typically will paste as unformatted (not in a table) text in both Wordpad and Outlook.
- If I open the query manually, copy the data and paste it, it works every time. This isn't quite end-user friendly.
***As I was writing this post, I had a thought: I cleared Clipboard data. After doing that, I could not recreate the issue. I toggled off the Clipboard history setting, and could not get the error to recur. So this would potentially point to a Clipboard data corruption--it somehow gets overwhelmed by the data that is being copied. I have never seen this error in other circumstances when copying anything into an email.***
So maybe I have the source, but I cannot guarantee my users won't also have their Clipboard History off. Has anyone ever encountered this and do you have thoughts on how to potentially avoid this?