Unable to execute VBA script for a shared Outlook inbox - Microsoft Community
- Get link
- X
- Other Apps
i'm using outlook 2013 , trying make vba script outputs how many messages in each category input date range. need able use script on shared inbox added personal inbox "additional mailbox", right work on personal inbox. how modify output shared inbox instead? also, need make include sub-folders of shared inbox? i've experimented different methods i've found in past posts, i'm not experienced enough vba scripting working properly. code have below:
sub categoriesemails() dim ofolder as mapifolder dim odict as object dim sstartdate as string dim senddate as string dim oitems as outlook.items dim sstr as string dim smsg as string on error resume next set ofolder = application.activeexplorer.currentfolder set odict = createobject("scripting.dictionary") sstartdate = inputbox("type start date (format mm/dd/yyyy)") senddate = inputbox("type end date (format mm/dd/yyyy)") set oitems = ofolder.items.restrict("[received] >= '" & sstartdate & "' , [received] <= '" & senddate & "'") oitems.setcolumns ("categories") for each aitem in oitems sstr = aitem.categories if not odict.exists(sstr) then odict(sstr) = 0 end if odict(sstr) = clng(odict(sstr)) + 1 next aitem smsg = "" for each akey in odict.keys smsg = smsg & akey & ": " & odict(akey) & vbcrlf next msgbox smsg set ofolder = nothing end sub
it particularly useful if export data excel , display categories folders, if difficult don't want complicate things further.
any or suggestions appreciated!
the script loops through items of current folder, need make desired folder active 1 before running script.
here´s sample recursive folder loop:
http://www.vboffice.net/en/developers/looping-recursively-through-folders-and-subfolders
there see "list folder contents". script move after setting folder doanything procedure. call doanything directly folder variable, , call fllopfolders ofolder.folders
Office / Outlook / Microsoft Office Programming / Office 2013
- Get link
- X
- Other Apps
Comments
Post a Comment