P
Paul
I have the following VBA script that takes a message and places a copy in a
local folder and one in shared folder. It works fine, but it is slow. Is
there something I can do to make it work faster?
I am not really a programmer and pasted this together with help from you all
previously.
Sub W7X80201()
Dim obj As Object
Dim i As Long
Dim Sel As Selection
Dim objFolder As Outlook.MAPIFolder
Dim objFolder1 As Outlook.MAPIFolder
Dim objInbox As Outlook.MAPIFolder
Dim objInbox1 As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace
Dim objNS1 As Outlook.NameSpace
Set objNS = Application.GetNamespace("MAPI")
Set objNS1 = Application.GetNamespace("MAPI")
'Assume these are mail folders
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders("Projects").Folders("City of
Scottsdale").Folders("W7X80201 - Airport - Seal Coat")
Set objInbox1 = objNS1.GetDefaultFolder(olPublicFoldersAllPublicFolders)
Set objFolder1 =
objNS1.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("Phoenix").Folders("Jobs").Folders("NAI").Folders("W7X80201 - Airport - Seal Coat")
Set Sel = Application.ActiveExplorer.Selection
For i = Sel.Count To 1 Step -1
Set obj = Sel(i)
Select Case True
Case (TypeOf obj Is Outlook.MailItem), (TypeOf obj Is
Outlook.ReportItem)
Set objCopy = obj.Copy
obj.Move objFolder
objCopy.Move objFolder1
End Select
Next
End Sub
local folder and one in shared folder. It works fine, but it is slow. Is
there something I can do to make it work faster?
I am not really a programmer and pasted this together with help from you all
previously.
Sub W7X80201()
Dim obj As Object
Dim i As Long
Dim Sel As Selection
Dim objFolder As Outlook.MAPIFolder
Dim objFolder1 As Outlook.MAPIFolder
Dim objInbox As Outlook.MAPIFolder
Dim objInbox1 As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace
Dim objNS1 As Outlook.NameSpace
Set objNS = Application.GetNamespace("MAPI")
Set objNS1 = Application.GetNamespace("MAPI")
'Assume these are mail folders
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders("Projects").Folders("City of
Scottsdale").Folders("W7X80201 - Airport - Seal Coat")
Set objInbox1 = objNS1.GetDefaultFolder(olPublicFoldersAllPublicFolders)
Set objFolder1 =
objNS1.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("Phoenix").Folders("Jobs").Folders("NAI").Folders("W7X80201 - Airport - Seal Coat")
Set Sel = Application.ActiveExplorer.Selection
For i = Sel.Count To 1 Step -1
Set obj = Sel(i)
Select Case True
Case (TypeOf obj Is Outlook.MailItem), (TypeOf obj Is
Outlook.ReportItem)
Set objCopy = obj.Copy
obj.Move objFolder
objCopy.Move objFolder1
End Select
Next
End Sub