Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 20th, 2005, 10:50 AM
ScriptHamWrk ScriptHamWrk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: East midlands in the UK.
Posts: 13 ScriptHamWrk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 57 sec
Reputation Power: 0
Angry VBA - MS Outlook - Runtime Error: Array out of bounds

I am a newbie struggling with the following code to run in MS Outlook. The purpose is to check all mail in my inbox and to separate it into folders using different strings in the subject line. The first step is to separate out all those commencing Read: or Delivered: etc. These are to be put in the AutoDel folder which I have created in Mailbox - JSP. Subsequent versions will use project numbers to segregate.

At the moment I get runtime error '-2147352567 (80020009)' Array index out of bounds. Line highlighted below
Can anyone see my error - it must be something fairly simple for experienced hackers but way beyond me.

I look forward to hearing from you.
Many thanks
ScriptHam

PS: very sorry - indenting not working

Code:
 
 
Sub AutoDel_1()
'*************************************************  *********
' Project to segregate/delete emails where subject line
' commences as per strSearch below e.g. Read: ...
'
' REFERENCES:
' Absolute Beginners Guide to VBA, QUE, PaulMcFedries
' http://www.mcfedries.com/abgvba/Chapter11.txt
'_________________________________________________  _________
'DECLARATIONS
'VARIABLES
Dim ns As NameSpace
Dim ib As MAPIFolder
Dim msg As MailItem
' Dim fldr As MAPIFolder experimented with - nogo
Dim strSearch1 As String
Dim strSearch2 As String
Dim strSearch3 As String
' Dim strsubject As String experimented with - nogo
 
'ASSIGN OBJECTS TO VARS.
Set ns = ThisOutlookSession.Session
Set ib = ns.GetDefaultFolder(olFolderInbox)
'Set fldr = ns.GetFolderFromID(AutoDel)
'INITIALISE VARS.
strSearch1 = Read:
strSearch2 = Delivered:
strSearch3 = "Delivery Status Notification (Relay)"
 
'CODE
For Each msg In ib.Items
'find opening words in the subject line and test = Read: or = Delivered: etc.
'if first appearance of str Read etc. is at position 1 then Move to AutoDel folder which exists
'Set strSubject = MailItem.subject experimented with - nogo
 
If InStr(1, msg.subject, strSearch1, 1) = 1 Then	 'first position in subject line, textual search
msg.Move ns.Folders(1).Folders(AutoDel)				 runtime error '-2147352567 (80020009)' Array index out of bounds
 
ElseIf InStr(1, msg.subject, strSearch2, 1) = 1 Then
MailItem.Move (AutoDel)
 
ElseIf InStr(1, msg.subject, strSearch3, 1) = 1 Then
MailItem.Move (AutoDel)
 
End If
 
Next
 

Reply With Quote
  #2  
Old April 20th, 2005, 10:05 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 32 m 23 sec
Reputation Power: 180
My guess is ns.Folders(1) isn't a valid array node.

Just guessing, can't you step through your code with the debugger to pin down the problem?
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old April 21st, 2005, 11:06 AM
ScriptHamWrk ScriptHamWrk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: East midlands in the UK.
Posts: 13 ScriptHamWrk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 57 sec
Reputation Power: 0
Thanks DougG.
I am struggling with the idea of an array node let alone how it relates to objects in Outlook VBA. Technically you are very probably correct. Presumably an array node is the memory location for array element zero.

Stepping through using the debug doesn't reveal much I regret.

It is only fair to tell you that I have put the same post on
http://www.theofficeexperts.com/for...read.php?t=4274
where I have had a different response but not much immediate progress.

I look forward to hearing any more ideas.
Many thanks
ScriptHam.

Reply With Quote
  #4  
Old April 21st, 2005, 11:41 AM
ScriptHamWrk ScriptHamWrk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: East midlands in the UK.
Posts: 13 ScriptHamWrk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 57 sec
Reputation Power: 0
Some more progress here http://www.theofficeexperts.com/for...read.php?t=4274 snice my post above.
In haste.
Thanks.
ScriptHam

Reply With Quote
  #5  
Old April 22nd, 2005, 03:42 AM
ScriptHamWrk ScriptHamWrk is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: East midlands in the UK.
Posts: 13 ScriptHamWrk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 57 sec
Reputation Power: 0
Now Complete. Many thanks DougG. Have also discovered what an array node is. For details of how question was resolved see the link in the post above.

Is there a special way to sign off or mark a thread as complete?

Good Luck
ScriptHam

Reply With Quote
  #6  
Old April 24th, 2005, 10:44 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 21 h 32 m 23 sec
Reputation Power: 180
I come back & find out you got it working, I'm glad to see that! You don't need to do anything special when you're done with a thread.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > VBA - MS Outlook - Runtime Error: Array out of bounds


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway