Results 1 to 5 of 5
  1. #1
    MTD072 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2017
    Posts
    14

    disable visual update duting control of outlook

    Good afternoon vaunted experts



    I'm not sure if what I'm asking is possible, as I've never seen reference to it.

    As a part of an application, I am downloading attachments from a collection of mail items within outlook from Access. I have no issue with doing this, but am wondering if there is a way to supress the screen updating during this processing. As things stand, the user will sit there and see 20+ emails open and the spawned save window run its course.

    Any ideas?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Post your code for review.

    I tested some code. I don't see any windows opening.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    MTD072 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2017
    Posts
    14
    Hi June.

    Sample code is as follows

    'Build collection
    For Each olmail In olnb.items
    For Each MsgAttachment In olmail.Attachments
    If Right(MsgAttachment.DisplayName, 3) = "TXT" Then
    collItems.Add olmail

    End If
    Next
    Next
    'Download txt files
    For Each olmail In collItems
    For Each olitm In olmail.Attachments
    olitm.SaveAsFile atchpth & i & ".txt"
    i = i + 1
    Next olitm
    Next

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    Really should post the object variable declaration and set lines as well.

    Here is my procedure that worked:
    Code:
    Sub SaveEmailAtt()
    Dim objNS As Outlook.NameSpace: Set objNS = GetNamespace("MAPI")
    Dim olFolder As Outlook.MAPIFolder: Set olFolder = objNS.GetDefaultFolder(olFolderInbox)
    Dim objAttachments As Outlook.Attachments
    Dim oMail As Outlook.MailItem
    Dim Item As Object
    Dim lngCount As Long, i As Integer
    For Each Item In olFolder.Items
        If TypeOf Item Is Outlook.MailItem Then
            Set oMail = Item
            Set objAttachments = oMail.Attachments
            lngCount = objAttachments.Count
            If lngCount > 0 Then
                ' We need to use a count down loop for removing items
                ' from a collection. Otherwise, the loop counter gets
                ' confused and only every other item is removed.
                For i = lngCount To 1 Step -1
                    objAttachments.Item(i).SaveAsFile "C:\Users\June\Forums\" & objAttachments.Item(i).FileName
                Next i
            End If
        End If
    Next
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    MTD072 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2017
    Posts
    14
    Apologies, June. I'm still familiarising myself with the forum rules and operation. I will endeavour to include variable declaration in the future.

    Thankyou for your assistance. I have adapted the code you provided and it has worked without issue.

    Regards

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 08-23-2017, 10:21 AM
  2. Replies: 6
    Last Post: 07-28-2017, 09:07 AM
  3. Disable Shift Control
    By gstylianou in forum Access
    Replies: 1
    Last Post: 06-25-2014, 08:29 AM
  4. Replies: 3
    Last Post: 07-20-2013, 12:53 PM
  5. Replies: 8
    Last Post: 03-12-2013, 11:49 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums