admin管理员组

文章数量:1399211

I have an Excel sheet that acts as a 'form' and uses VBA to walk users through the workflow. When the next persons input is needed, the user presses a 'Submit' button and VBA triggers an email to inform the next person of their action. This is the code that sends the email:

            'will open email for sucsessful submit
            ' /
            Dim OutlookApp As Object
            Dim OutlookMail As Object
    
            ' Create a new instance of Outlook
            Set OutlookApp = CreateObject("Outlook.Application")
    
            ' Create a new email
            Set OutlookMail = OutlookApp.CreateItem(0)
    
            ' Set the properties of the email
            With OutlookMail
                .To = ActiveWorkbook.Worksheets("sheet").Range("A7")
                .CC = ""
                .BCC = ""
                .Subject = ActiveWorkbook.Worksheets("sheet").Range("A8")
                .Body = ActiveWorkbook.Worksheets("sheet").Range("A9")
                .Display 'Use .Send instead of .Display to send the email without displaying it
            End With
    
            ' Clean up
            Set OutlookMail = Nothing
            Set OutlookApp = Nothing

This works. I do not get any errors with this.

Some users got the following error:

But this was resolved by updating Microsoft Office which was available through IT.

Then a second problem occurred, with the same error, but only situationally:

If the user presses the 'Submit' button with Outlook OPEN, the email generation will fail. If they CLOSE Outlook, and press 'Submit', it works fine. The error is the SAME as above:

What could possibly cause this? This does not happen on my machine at all, which has made troubleshooting tough as it simply does not happen to me. Does anyone have any thoughts? Thanks in advance.

本文标签: