Outlook 2007 Error in Excel VBA Script

I am using this code, which works fine, to email a worksheet from within an Excel VBA script...
Dim outlookApp As Object
Dim outlookMail As Object
Dim wbTemp As Workbook
Dim strFileName As String

Set outlookApp = CreateObject("Outlook.Application")
Set outlookMail = outlookApp.CreateItem(0)


Set wbTemp = ActiveWorkbook

wbTemp.SaveAs "C:\Temp\" & wbTemp.Sheets(1).Name & ".xlsx", xlOpenXMLWorkbook

strFileName = wbTemp.FullName

wbTemp.Close False

With outlookMail
    .To = "test@yourco.com"
    .Subject = "Requested Spreadsheet"
    .BodyFormat = 2
    .HTMLBody = "Good morning!,<p>Attached is the spreadsheet you requested."
    .Attachments.Add strFileName
    .Importance = olImportanceHigh
End With

Set outlookMail = Nothing
Set outlookApp = Nothing

Kill strFileName
As noted, the script works fine and runs to completion, but does generate an Outlook 2007 error message as shown in the attached file. I suspect this has to do with the version of Outlook being 2007, as I do not get the error when test-running the code on a machine with Outlook 2013. If any of you know how to adapt this code so as to eliminate the error, please post!


Glenn StearnsAnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
What if you replace the line .Importance = olImportanceHigh with .Importance = 2.
Does it work then?
Glenn StearnsAnalystAuthor Commented:

No - same error occurs with your recommended change.


Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Sorry! No idea.
See if this link gives you an idea.
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Bill PrewIT / Software Engineering ConsultantCommented:
Searching for the title of your error box "ADX Loader" also yields some results you might look at.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NorieAnalyst Assistant Commented:
Which version of Excel are you using and which version of Excel was used to create the workbook you want to attach a sheet from?
Glenn StearnsAnalystAuthor Commented:
The version of Office on the machine running the code is Office 2007. Spreadsheet and VBA are in that version of Excel. The VBA script only runs in Excel 2007. It is extensive and has several commands in it which are not compatible with Excel 2013. I have tested the email part of the script in a similar situation on another machine running Office 2013 and I do not get the error. From what I'm reading online, this is likely an Outlook 2007 error and not an Excel VBA problem - something having to do with conflicting add-ins to Outlook 2007, which is what I am checking now. I believe this because I get the error when starting Outlook 2007 alone from the start menu.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.