I'm trying to use AttachmentSelection as part of a workaround to drag-and-drop Outlook attachments into Access, but the roadblock I've run into is that Explorer.AttachmentSelection doesn't give me anything, and I can only use Inspector.AttachmentSelection on emails open in their own window (there's no active Inspector for an item in the Preview Pane) - and the source email folder is always in preview mode.
So okay, fine, I tried using GetInspector on the current MailItem, and although that Inspector object seems otherwise fine and points to the correct email, AttachmentSelection is **still **empty (but fine if the email is open in a separate window).
Code snippet (all variables have been declared with early binding; I tried late binding on MailItem and Inspector objects, but it made no difference):
If olApp is Nothing Then Set olApp = GetObject(, "Outlook.Application")
Set olExp = olApp.ActiveExplorer
Set olSel = olExp.Selection
Set olMsg = olSel(1)
Set olInsp = olMsg.GetInspector
Set olAttach = olInsp.AttachmentSelection
AttachCount = olAttach.Count
If AttachCount > 0 Then
[Loop through attachments]
EndIf
If the email is open in a separate window, AttachCount is the number of attachments selected; if it's in the Preview Pane, it's zero.
Try
Application.ActiveInspectorinstead. Is it showing the attachment preview at the time of the call? If not, Outlook won't think it is selected.For the reading pane, you need to use
Explorer.AttachmentSelection: