Using Excel VBA to create email in Outlook 2010 from template -
i have code worked in excel/outlook 2003 on xp, i'm running windows 7 excel/outlook 2010 , receive error:
run-time error '287': application-defined or object-defined error.
my code based on answer in: send email excel 2007 vba using outlook template & set variables
i'm creating outlook object , mailitem this:
dim myolapp dim myolitem set myolapp = createobject("outlook.application") set myolitem = myolapp.createitemfromtemplate(range("oftlocation").value) 'user defined location
the error appears after reference myolitem
, code replacing references in .htmlbody
amending .body
makes no difference, same error shows.
my references in vba set to:
- vba
- microsoft excel 14.0 object library
- ole automation
- microsoft office 14.0 object library
- microsoft forms 2.0 object library
- microsoft scripting runtime
this isnt answer yet want collect happening in comments since feel best direction have seen far.
i have tested code in have in question , works fine me using outlook 2010 , excel 2010.
when excel tries interact outlook programmatic access settings come play.
i beleive setting warning state if antivirus out of date. similar way windows detects status of antivirus. when access outlook excel prompt asking permissiong action. in case, , under normal circumstances, allow action , code proceed normal.
however have seen people catch error 287 logic user hit no prompt. not appear case you. need take @ trust center settings in outlook programmatic access in concerned. there interaction antivirus , trust center provide information well. settings there disabled if not running outlook administrator rights. let me know come with.
i havent been explicit until draw attention av well. 1 of things try stop. perhaps there rule fired preventing this.
either way should able test in environment see if maybe system in particular. think both agree not code since know works elsewhere.
Comments
Post a Comment