VBA Keeps popping up?

P

PaulW

Hi there, i've set up a macro in Outlook to save some attachments. But the
code keeps coming up on screen, not when I run it, but randomly while i'm
working on other things.

It mostly seems to appear on my screen when the screen saver is activated,
anyone know why? and/or how I can stop it?

Sub GetAttachments()
' This Outlook macro checks a the Outlook Inbox for messages
' with attached files (of any type) and saves them to disk.
' NOTE: make sure the specified save folder exists before
' running the macro.
' Declare variables
Dim ns As NameSpace
Dim Inbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
i = 0
' Check each message for attachments
For Each Item In Inbox.Items
' Save any attachments found
For Each Atmt In Item.Attachments
' This path must exist! Change folder name as necessary.
FileName = "S:\Close Assistance\Main Files\Download
Reports\Telephone Calls\Pre Visit Reports\" & Format(Item.CreationTime,
"dd-mm-yy ") & Atmt.FileName
If Item.SenderName = "Power Desk" Then
Atmt.SaveAsFile FileName
End If
i = i + 1
Next Atmt
Next Item
' Clear memory
GetAttachments_exit:
Set Atmt = Nothing
Set Item = Nothing
Set ns = Nothing
Exit Sub

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top