A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook 2000 Macro problem - Please help



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 16th 07, 04:19 PM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 2
Default Outlook 2000 Macro problem - Please help

Hello

I have been using the below email for a while now;

I just have to keep running it to bypass by error message but now I am
receiving too many emails to keep doing this,

Can someone please tell me how to resolve this run time error?

Run time error '-2147352567 (80020009)
Array index out of bounds

My macro is

Public Function StripChars(ByVal sStr) As String
sStr = Replace(sStr, """", "")
sStr = Replace(sStr, "'", "")
sStr = Replace(sStr, ":", "")
sStr = Replace(sStr, "/", "-")
sStr = Replace(sStr, "\", "-")
sStr = Replace(sStr, "?", "")
StripChars = sStr
End Function

Sub CopyEmailMsg()


Dim myApp As Application
Dim myNS As NameSpace
Dim myFolder As Object
Dim myItems As Outlook.MailItem
'Dim oAttachments As Outlook.Attachments


Set myApp = New Outlook.Application
Set myNS = myApp.GetNamespace("MAPI")
Set myFolder =
myNS.GetDefaultFolder(olFolderInbox).Folders("Clie nt").Folders("Subclient")
'Set myItems = myFolder.Items
Set myDestFolder = myFolder.Folders("Subclient1")


For Count = 1 To myFolder.Items.Count
Set myMail = myFolder.Items(Count)


myMail.SaveAs "C:\emails\" & StripChars(myMail.Subject) & ".msg",
olMSG


myMail.Move myDestFolder
Next Count

MsgBox "The emails have been copied and saved"


End Sub

It does work but the only real problem is that I have to keep running
it in order for it to process all the emails.

I appreciate anyone's help with a revised code....I'm not an expert in
this area,

Thanks so much

Andrea

  #2  
Old May 16th 07, 04:40 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Outlook 2000 Macro problem - Please help



use a backwards counting loop

For Count = myFolder.Items.Count To 1 step -1
....
Next

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - Categorize Outlook data:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am 16 May 2007 08:19:49 -0700 schrieb :

Hello

I have been using the below email for a while now;

I just have to keep running it to bypass by error message but now I am
receiving too many emails to keep doing this,

Can someone please tell me how to resolve this run time error?

Run time error '-2147352567 (80020009)
Array index out of bounds

My macro is

Public Function StripChars(ByVal sStr) As String
sStr = Replace(sStr, """", "")
sStr = Replace(sStr, "'", "")
sStr = Replace(sStr, ":", "")
sStr = Replace(sStr, "/", "-")
sStr = Replace(sStr, "\", "-")
sStr = Replace(sStr, "?", "")
StripChars = sStr
End Function

Sub CopyEmailMsg()


Dim myApp As Application
Dim myNS As NameSpace
Dim myFolder As Object
Dim myItems As Outlook.MailItem
'Dim oAttachments As Outlook.Attachments


Set myApp = New Outlook.Application
Set myNS = myApp.GetNamespace("MAPI")
Set myFolder =

myNS.GetDefaultFolder(olFolderInbox).Folders("Clie nt").Folders("Subclient")
'Set myItems = myFolder.Items
Set myDestFolder = myFolder.Folders("Subclient1")


For Count = 1 To myFolder.Items.Count
Set myMail = myFolder.Items(Count)


myMail.SaveAs "C:\emails\" & StripChars(myMail.Subject) & ".msg",
olMSG


myMail.Move myDestFolder
Next Count

MsgBox "The emails have been copied and saved"


End Sub

It does work but the only real problem is that I have to keep running
it in order for it to process all the emails.

I appreciate anyone's help with a revised code....I'm not an expert in
this area,

Thanks so much

Andrea

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Macro problem Victor Delta Outlook and VBA 2 December 9th 06 06:12 PM
vba macro to print email and attachments outlook 2000 Dan over in IT Outlook and VBA 2 June 7th 06 08:08 PM
Macro Problem Guy Outlook and VBA 4 May 18th 06 04:08 AM
put macro into MS Outlook 2000 David C Outlook and VBA 4 January 25th 06 05:00 PM
Outlook 2000 - Button to run Macro then open Database David C Outlook and VBA 1 January 25th 06 03:44 PM


All times are GMT +1. The time now is 08:20 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.