Do you have Outlook open with a message open when you open the db?
The error I believe is caused by the fact that you do not have an Outlook explorer window open with an email message loaded.
This updated function catches that and displays a message, modify as you wish:
Code:
Public Function GrabMail() As String
Dim MailBody As Outlook.MailItem ' changed this to Outlook.MailItem
Dim outApp As Outlook.Application
Dim oExplorer As Outlook.Explorer
Set outApp = CreateObject("Outlook.Application")
Set oExplorer = outApp.ActiveExplorer
If oExplorer Is Nothing Then
MsgBox "No Outlook explorer open!", vbCritical, "No Outlook Explorer"
Exit Function
Else
If TypeName(outApp.ActiveExplorer.Selection.Item(1)) = "MailItem" Then
Set MailBody = outApp.ActiveExplorer.Selection.Item(1)
MailBody.GetInspector().WordEditor.Range.FormattedText.Copy
Forms!frmMainMenu!txtMailMessage.SetFocus ' = MailBody
'Debug.Print MailBody.GetInspector().WordEditor.Range.FormattedText
DoCmd.RunCommand acCmdPaste
End If
End If
End Function
Cheers,