Outlook macro runs through 250 iterations before failing with error

后端 未结 2 1926
青春惊慌失措
青春惊慌失措 2021-01-26 11:08

Description:

I have an Outlook macro that loops through selected emails in a folder and writes down some info to a .csv file. It works perfectly up unti

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-26 12:06

    To solve this problem I used the following rules:

    the "objOutlook.ActiveExplorer" has limited range (250 objects).

    but object create for each email is unlimited.

    for exemple:

    sub Over250()
    
      Total = objOutlook.ActiveExplorer.Selection.Count
    
      For X = 1 to Total
    
        Set objOutlook = CreateObject("Outlook.Application")
        Set ObjExplorer = objOutlook.ActiveExplorer     
    
       '**** DO YOU THINGS****
    
        Set objOutlook = Nothing
        Set ObjExplorer = Nothing
    
      Next X
    
    end sub
    

提交回复
热议问题