excel - VBA not Recognizing MAPI -


i'm using vba enter outlook folder , put message body cell. on

 set ns = getnamespace("mapi") 

i error "automation error library not registered". have following outlook related references selected (within excel):

  • outlook 14.0 object library,
  • outlook sharepoint social provider,
  • outlook social provider extensibility,
  • outlook view control

i'm using excel 2010. entire code follows. appreciated.

dim ns namespace dim inbox mapifolder dim item object dim atmt attachment dim filename string dim integer dim subfolder mapifolder dim subsubfolder mapifolder dim variablename name dim working workbook dim sheet worksheet   set ns = getnamespace("mapi") set inbox = ns.getdefaultfolder(olfolderinbox) set subfolder = inbox.folders("xx")  set subsubfolder = subfolder.folders("xxxx") set working = thisworkbook set sheet = working.worksheets("sheet1")  if subsubfolder.items.count > 0   each item in subsubfolder.items sheet.range("a1") = item.body next item  end if 

namespace() valid in outlook vba since there intrinsic application variable points outlook.application object , variable global. i.e. of properties , methods available without specifying "application.*"

in case of excel vba, application points instance of excel.application object, must explicitly create , initialize outlook.application object:

set olapp = createobject("outlook.application") set ns = olapp.getnamespace("mapi") ... 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -