Application.ScreenUpdating = FALSE

  • Thread starter Thread starter Jac Tremblay
  • Start date Start date
J

Jac Tremblay

Note: I posted this question 2 weeks ago and got no
answer. I repost it now in this general category hoping
for something. Thank you.

There is no such command as this one in Outlook like there
is in Word and Excel:

Application.ScreenUpdating = FALSE

If I have to open and display thousands of mail messages,
what would be the best way to make the entire process the
fastest possible?

Here is some of the code I use (there is over 6 pages of
it)...

' For each mail item.
For intNbMail = 1 To oFldr.Items.Count

Set msgMessage = oFldr.Items(intNbMail)

' Check if it is a mail message (olMail).
If msgMessage.Class <> olMail Then GoTo NextMessage

' Check if its size is within limits.
If msgMessage.Size < lngLimit Then GoTo NextMessage

' Check if it contains at least one attachment.
intNbAttach = msgMessage.Attachments.Count
If intNbAttach = 0 Then GoTo NextMessage

' Display the message only if it has to be treated.
msgMessage.Display

' For each attachment.
For intI = intNbAttach To 1 Step -1

Set objAttach = msgMessage.Attachments.Item(intI)

' Store the file name in a variable.
strFileName = objAttach.FileName

.....

' Save the file to the user's hard disk.
On Error GoTo errSavingFile
objAttach.SaveAsFile strPath & strFileName

' Delete the attachment.
objAttach.Delete

.....

' Add a link to the document at the end of the
message.
msgMessage.Body = msgMessage.Body & vbCrLf & _
"""" & "<" & "File://" & strPath & strFileName
& ">" & """"

.....

Next intI ' intNbAttach

.....
' Add a note at the begining of the message.
msgMessage.Body = strBeginningOfNote &
msgMessage.Body

' Save and close the message.
msgMessage.Close olSave

.....

GoTo NextMessage

errSavingFile:

' The attachment could not be saved.
' Close the message without saving it.
msgMessage.Close olDiscard

' Free memory used.
Set msgMessage = Nothing
Set objAttach = Nothing
.....

' Display a message to the user.
MsgBox "NOTE: The process did not end well..." , _
vbCritical

Exit Sub

.....

NextMessage:
On Error Resume Next
msgMessage.Close olDiscard
Next ' intNbMail

.....

Thank you
..
 
Back
Top