I am trying to email a screenshot of userForm with outlook. The spreadsheet is saved in our company google drive and works without a hitch in a couple of computers, but in most It stops with the above error.
The code for the email function is:
Function outlookEmail()
Dim doc As Object
Dim OutApp As Outlook.Application 'this is an outlook object
Dim oOutlookEmail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set oOutlookEmail = OutApp.CreateItem(0)
On Error Resume Next
Set OutApp = GetObject(, "Outlook.Application")
If Err.Number > 0 Then Set OutApp = CreateObject("Outlook.Application")
On Error GoTo 0
Application.SendKeys "(%{1068})"
DoEvents
With oOutlookEmail
.Display
Set doc = .GetInspector.WordEditor
doc.Range(0, 0).Paste
.To = sDetail.Cells(myRow, headerDict.item("email"))
.Subject = "documents for you"
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys "%s"
.Send
End With
End Function
the error usually occurs in the set doc line.