我編寫了這段代碼,用於尋找所有郵箱內的所有郵件中的特定字符串(平均每個郵箱100個郵箱(總計10個郵箱))。Outlook VBA代碼極其緩慢
事情是......代碼有效,但它太慢了,甚至凍結了Outlook。
有什麼我可以做,使其更快?
Sub InboxSeeker(Word As String)
Dim u As Integer, AddressArr() As String, Users() As String, Element As Variant, Label As Control
GetOutlook
AddressArr = QryLoop_Specific("Company", "Address", "Users", "Team", "Samples", "Address")
For Each Element In AddressArr
Set lFolder = GetFolder(Element)
Set lItems = GetFolder(Element).Items
For Each lMsg In lItems
If InStr(1, lMsg.Body, Word, vbTextCompare) > 0 Or InStr(1, lMsg.Subject, Word, vbTextCompare) > 0 Then
DoEvents
ReDim Preserve Users(u)
Users(u) = QrySingleResult("Company", "FullName", "Users", "Address", Element)
u = u + 1
End If
Next lMsg
Next Element
一兩件事:我測試剛剛在所有科目檢查代碼,它的效果要好得多。但我還需要檢查屍體,這部分似乎是問題所在。 – AndroidDev 2015-04-02 20:10:02